Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution {
- public:
- bool searchMatrix(vector<vector<int>>& matrix, int target) {
- int rows = matrix.size(), cols = matrix[0].size();
- int curX = rows-1, curY = 0;
- while(curX >= 0 && curY < cols){
- int curr = matrix[curX][curY];
- if(curr == target)
- return true;
- else if(curr > target)
- curX--;
- else
- curY++;
- }
- return false;
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement