Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit e42339a

Browse files
authored
feat: add rust solution to lc problem: No.2639 (doocs#1137)
1 parent ce92293 commit e42339a

File tree

3 files changed

+52
-0
lines changed

3 files changed

+52
-0
lines changed

‎solution/2600-2699/2639.Find the Width of Columns of a Grid/README.md‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,25 @@ function findColumnWidth(grid: number[][]): number[] {
160160
}
161161
```
162162

163+
### **Rust**
164+
165+
```rust
166+
impl Solution {
167+
pub fn find_column_width(grid: Vec<Vec<i32>>) -> Vec<i32> {
168+
let mut ans = vec![0; grid[0].len()];
169+
170+
for row in grid.iter() {
171+
for (j, num) in row.iter().enumerate() {
172+
let width = num.to_string().len() as i32;
173+
ans[j] = std::cmp::max(ans[j], width);
174+
}
175+
}
176+
177+
ans
178+
}
179+
}
180+
```
181+
163182
### **...**
164183

165184
```

‎solution/2600-2699/2639.Find the Width of Columns of a Grid/README_EN.md‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,25 @@ function findColumnWidth(grid: number[][]): number[] {
142142
}
143143
```
144144

145+
### **Rust**
146+
147+
```rust
148+
impl Solution {
149+
pub fn find_column_width(grid: Vec<Vec<i32>>) -> Vec<i32> {
150+
let mut ans = vec![0; grid[0].len()];
151+
152+
for row in grid.iter() {
153+
for (j, num) in row.iter().enumerate() {
154+
let width = num.to_string().len() as i32;
155+
ans[j] = std::cmp::max(ans[j], width);
156+
}
157+
}
158+
159+
ans
160+
}
161+
}
162+
```
163+
145164
### **...**
146165

147166
```
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
impl Solution {
2+
pub fn find_column_width(grid: Vec<Vec<i32>>) -> Vec<i32> {
3+
let mut ans = vec![0; grid[0].len()];
4+
5+
for row in grid.iter() {
6+
for (j, num) in row.iter().enumerate() {
7+
let width = num.to_string().len() as i32;
8+
ans[j] = std::cmp::max(ans[j], width);
9+
}
10+
}
11+
12+
ans
13+
}
14+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /