diff options
author | Jack Sangdahl <[email protected]> | 2025-06-27 12:23:02 -0600 |
---|---|---|
committer | Jack Sangdahl <[email protected]> | 2025-06-27 12:23:02 -0600 |
commit | a96b65cbfad7f62f3db6b2eab105e4e25c0414c5 (patch) | |
tree | e2a2b3f49f9fb741be81415266ac93e74cff42ec /other/count_negative_num_matrix.cpp | |
parent | 694ad5ed71edcb1deccab54b72d706b779918276 (diff) | |
download | leetcode-a96b65cbfad7f62f3db6b2eab105e4e25c0414c5.tar.gz leetcode-a96b65cbfad7f62f3db6b2eab105e4e25c0414c5.zip |
chore: remove old cpp and rust solutions
Diffstat (limited to 'other/count_negative_num_matrix.cpp')
-rw-r--r-- | other/count_negative_num_matrix.cpp | 37 |
1 files changed, 0 insertions, 37 deletions
diff --git a/other/count_negative_num_matrix.cpp b/other/count_negative_num_matrix.cpp deleted file mode 100644 index f7c776d..0000000 --- a/other/count_negative_num_matrix.cpp +++ /dev/null @@ -1,37 +0,0 @@ -// 1351. Count Negative Numbers in a Sorted Matrix -#include "leetcode.h" - -// given an 'm x n' matrix 'grid' which is sorted in non-increasing order both -// row-wise and column-wise, return the number of negative numbers in 'grid' - -class Solution { -public: - int countNegatives(vvd & grid) { - int ans = 0; - for (vector<int> row : grid) - for (int i : row) - if (i < 0) - ans++; - return ans; - for (vector<int> row : grid) - ans += upper_bound(row.rbegin(), row.rend(), -1) - row.rbegin(); - return ans; - int m = grid.size(), n = grid[0].size(), r = 0, c = n - 1; - while (r < m) { - while (c >= 0 && grid[r][c] < 0) - c--; - ans += n - c - 1; - r++; - } - return ans; - } -}; - -int main() { - Solution obj; - vvd - g1 = {{4, 3, 2, -1}, {3, 2, 1, -1}, {1, 1, -1, -2}, {-1, -1, -2, -3}}; - vvd g2 = {{3, 2}, {1, 0}}; - printf("%d\n", obj.countNegatives(g1)); // expect: 8 - printf("%d\n", obj.countNegatives(g2)); // expect: 0 -} |