Skip to content

Commit 9327c18

Browse files
authored
feat: add ts solution to lc problem: No.2500 (#1301)
1 parent 7096932 commit 9327c18

File tree

3 files changed

+58
-0
lines changed

3 files changed

+58
-0
lines changed

solution/2500-2599/2500.Delete Greatest Value in Each Row/README.md

+21
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,27 @@ impl Solution {
175175
}
176176
```
177177

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+
178199
### **...**
179200

180201
```

solution/2500-2599/2500.Delete Greatest Value in Each Row/README_EN.md

+21
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,27 @@ impl Solution {
153153
}
154154
```
155155

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+
156177
### **...**
157178

158179
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
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+
}

0 commit comments

Comments
 (0)