Advertisement
momo2345

negative number

Aug 31st, 2020
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.28 KB | None | 0 0
  1. class Solution {
  2. public:
  3.     int countNegatives(vector<vector<int>>& grid) {
  4.     int ans=0;
  5.      for(auto u : grid)
  6.      {
  7.          reverse(u.begin(),u.end());
  8.         int l=lower_bound(u.begin(),u.end(),0)-u.begin();
  9.          ans+=l;
  10.      }
  11.         return ans;
  12.     }
  13. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement