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

141. Linked List Cycle

67. Add Binary

88. Merge Sorted Array