1351. Count Negative Numbers in a Sorted Matrix

 class Solution {

public:

    int countNegatives(vector<vector<int>>& grid) {

        int d=0;

        for(int i=0;i<grid.size();i++){

            for(int j=0;j<grid[i].size();j++){

                if(grid[i][j]<0)

                    d++;

            }

        }

        return d;

    }

};

Comments

Popular posts from this blog

1431. Kids With the Greatest Number of Candies

125. Valid Palindrome

771. Jewels and Stones