File tree 3 files changed +79
-0
lines changed
solution/2500-2599/2500.Delete Greatest Value in Each Row
3 files changed +79
-0
lines changed Original file line number Diff line number Diff line change @@ -147,6 +147,34 @@ func deleteGreatestValue(grid [][]int) (ans int) {
147
147
}
148
148
```
149
149
150
+ ### ** Rust**
151
+
152
+ ``` rust
153
+ impl Solution {
154
+ pub fn delete_greatest_value (grid : Vec <Vec <i32 >>) -> i32 {
155
+ let mut grid = grid ;
156
+ for i in 0 .. grid . len () {
157
+ grid [i ]. sort ();
158
+ }
159
+
160
+ let mut ans = 0 ;
161
+ for j in 0 .. grid [0 ]. len () {
162
+ let mut mx = 0 ;
163
+
164
+ for i in 0 .. grid . len () {
165
+ if grid [i ][j ] > mx {
166
+ mx = grid [i ][j ];
167
+ }
168
+ }
169
+
170
+ ans += mx ;
171
+ }
172
+
173
+ ans
174
+ }
175
+ }
176
+ ```
177
+
150
178
### ** ...**
151
179
152
180
```
Original file line number Diff line number Diff line change @@ -125,6 +125,34 @@ func deleteGreatestValue(grid [][]int) (ans int) {
125
125
}
126
126
```
127
127
128
+ ### ** Rust**
129
+
130
+ ``` rust
131
+ impl Solution {
132
+ pub fn delete_greatest_value (grid : Vec <Vec <i32 >>) -> i32 {
133
+ let mut grid = grid ;
134
+ for i in 0 .. grid . len () {
135
+ grid [i ]. sort ();
136
+ }
137
+
138
+ let mut ans = 0 ;
139
+ for j in 0 .. grid [0 ]. len () {
140
+ let mut mx = 0 ;
141
+
142
+ for i in 0 .. grid . len () {
143
+ if grid [i ][j ] > mx {
144
+ mx = grid [i ][j ];
145
+ }
146
+ }
147
+
148
+ ans += mx ;
149
+ }
150
+
151
+ ans
152
+ }
153
+ }
154
+ ```
155
+
128
156
### ** ...**
129
157
130
158
```
Original file line number Diff line number Diff line change
1
+ impl Solution {
2
+ pub fn delete_greatest_value ( grid : Vec < Vec < i32 > > ) -> i32 {
3
+ let mut grid = grid;
4
+ for i in 0 ..grid. len ( ) {
5
+ grid[ i] . sort ( ) ;
6
+ }
7
+
8
+ let mut ans = 0 ;
9
+ for j in 0 ..grid[ 0 ] . len ( ) {
10
+ let mut mx = 0 ;
11
+
12
+ for i in 0 ..grid. len ( ) {
13
+ if grid[ i] [ j] > mx {
14
+ mx = grid[ i] [ j] ;
15
+ }
16
+ }
17
+
18
+ ans += mx;
19
+ }
20
+
21
+ ans
22
+ }
23
+ }
You can’t perform that action at this time.
0 commit comments