[leetcode]Count Negative Numbers in a Sorted Matrix

jun·2021년 4월 11일
0
post-thumbnail

유의할점

r.begin(), rend() 사용.

풀이

코드

C++


class Solution {
public:
    int countNegatives(vector<vector<int>>& grid) {
        int res = 0;
        for(auto g : grid){
            res += upper_bound(g.rbegin(),g.rend(),-1) - g.rbegin();
        }
        return res;
    }
};
profile
Computer Science / Algorithm / Project / TIL

0개의 댓글