Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,26 @@ class Solution {
}
```

### **TypeScript**

```ts
function countNegatives(grid: number[][]): number {
let m = grid.length, n = grid[0].length;
let i = 0, j = n - 1;
let ans = 0;
while (i < m && j > -1) {
let cur = grid[i][j];
if (cur < 0) {
j--;
ans += (m - i);
} else {
i++;
}
}
return ans;
};
```

### **C++**

```cpp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,26 @@ class Solution {
}
```

### **TypeScript**

```ts
function countNegatives(grid: number[][]): number {
let m = grid.length, n = grid[0].length;
let i = 0, j = n - 1;
let ans = 0;
while (i < m && j > -1) {
let cur = grid[i][j];
if (cur < 0) {
j--;
ans += (m - i);
} else {
i++;
}
}
return ans;
};
```

### **C++**

```cpp
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
function countNegatives(grid: number[][]): number {
let m = grid.length, n = grid[0].length;
let i = 0, j = n - 1;
let ans = 0;
while (i < m && j > -1) {
let cur = grid[i][j];
if (cur < 0) {
j--;
ans += (m - i);
} else {
i++;
}
}
return ans;
};