Skip to content

Commit d30b6bd

Browse files
authored
feat: add rust solution to lc problem: No.2549 (#1222)
Signed-off-by: xiaolatiao <1628652790@qq.com>
1 parent 9295792 commit d30b6bd

File tree

3 files changed

+37
-0
lines changed

3 files changed

+37
-0
lines changed

solution/2500-2599/2549.Count Distinct Numbers on Board/README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,20 @@ function distinctIntegers(n: number): number {
119119
}
120120
```
121121

122+
### **Rust**
123+
124+
```rust
125+
impl Solution {
126+
pub fn distinct_integers(n: i32) -> i32 {
127+
if n == 1 {
128+
return 1;
129+
}
130+
131+
n - 1
132+
}
133+
}
134+
```
135+
122136
### **...**
123137

124138
```

solution/2500-2599/2549.Count Distinct Numbers on Board/README_EN.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,20 @@ function distinctIntegers(n: number): number {
101101
}
102102
```
103103

104+
### **Rust**
105+
106+
```rust
107+
impl Solution {
108+
pub fn distinct_integers(n: i32) -> i32 {
109+
if n == 1 {
110+
return 1;
111+
}
112+
113+
n - 1
114+
}
115+
}
116+
```
117+
104118
### **...**
105119

106120
```
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
impl Solution {
2+
pub fn distinct_integers(n: i32) -> i32 {
3+
if n == 1 {
4+
return 1;
5+
}
6+
7+
n - 1
8+
}
9+
}

0 commit comments

Comments
 (0)