File tree 3 files changed +58
-0
lines changed
solution/2500-2599/2500.Delete Greatest Value in Each Row
3 files changed +58
-0
lines changed Original file line number Diff line number Diff line change @@ -175,6 +175,27 @@ impl Solution {
175
175
}
176
176
```
177
177
178
+ ### ** TypeScript**
179
+
180
+ ``` ts
181
+ function deleteGreatestValue(grid : number [][]): number {
182
+ for (const row of grid ) {
183
+ row .sort ((a , b ) => a - b );
184
+ }
185
+
186
+ let ans = 0 ;
187
+ for (let j = 0 ; j < grid [0 ].length ; ++ j ) {
188
+ let t = 0 ;
189
+ for (let i = 0 ; i < grid .length ; ++ i ) {
190
+ t = Math .max (t , grid [i ][j ]);
191
+ }
192
+ ans += t ;
193
+ }
194
+
195
+ return ans ;
196
+ }
197
+ ```
198
+
178
199
### ** ...**
179
200
180
201
```
Original file line number Diff line number Diff line change @@ -153,6 +153,27 @@ impl Solution {
153
153
}
154
154
```
155
155
156
+ ### ** TypeScript**
157
+
158
+ ``` ts
159
+ function deleteGreatestValue(grid : number [][]): number {
160
+ for (const row of grid ) {
161
+ row .sort ((a , b ) => a - b );
162
+ }
163
+
164
+ let ans = 0 ;
165
+ for (let j = 0 ; j < grid [0 ].length ; ++ j ) {
166
+ let t = 0 ;
167
+ for (let i = 0 ; i < grid .length ; ++ i ) {
168
+ t = Math .max (t , grid [i ][j ]);
169
+ }
170
+ ans += t ;
171
+ }
172
+
173
+ return ans ;
174
+ }
175
+ ```
176
+
156
177
### ** ...**
157
178
158
179
```
Original file line number Diff line number Diff line change
1
+ function deleteGreatestValue ( grid : number [ ] [ ] ) : number {
2
+ for ( const row of grid ) {
3
+ row . sort ( ( a , b ) => a - b ) ;
4
+ }
5
+
6
+ let ans = 0 ;
7
+ for ( let j = 0 ; j < grid [ 0 ] . length ; ++ j ) {
8
+ let t = 0 ;
9
+ for ( let i = 0 ; i < grid . length ; ++ i ) {
10
+ t = Math . max ( t , grid [ i ] [ j ] ) ;
11
+ }
12
+ ans += t ;
13
+ }
14
+
15
+ return ans ;
16
+ }
You can’t perform that action at this time.
0 commit comments