Skip to content

Commit f2c1210

Browse files
authored
Update README_EN.md
1 parent 12d910f commit f2c1210

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

solution/1300-1399/1399.Count Largest Group/README_EN.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,36 @@ function countLargestGroup(n: number): number {
188188
}
189189
```
190190

191+
#### Rust
192+
193+
```rust
194+
impl Solution {
195+
pub fn count_largest_group(n: i32) -> i32 {
196+
let mut cnt = vec![0; 40];
197+
let mut ans = 0;
198+
let mut mx = 0;
199+
200+
for i in 1..=n {
201+
let mut s = 0;
202+
let mut x = i;
203+
while x > 0 {
204+
s += x % 10;
205+
x /= 10;
206+
}
207+
cnt[s as usize] += 1;
208+
if mx < cnt[s as usize] {
209+
mx = cnt[s as usize];
210+
ans = 1;
211+
} else if mx == cnt[s as usize] {
212+
ans += 1;
213+
}
214+
}
215+
216+
ans
217+
}
218+
}
219+
```
220+
191221
<!-- tabs:end -->
192222

193223
<!-- solution:end -->

0 commit comments

Comments
 (0)