leetcode

Solution to some Leetcode problems written in C++
git clone git://git.dimitrijedobrota.com/leetcode.git
Log | Files | Refs | README | LICENSE

0240.cpp (389B)


0 class Solution { 1 public: 2 bool searchMatrix(vector<vector<int>> &matrix, int target) { 3 int n = matrix.size(), m = matrix[0].size(), x = 0, y = m - 1; 4 while (x < n && y >= 0) { 5 if (matrix[x][y] == target) return true; 6 if (matrix[x][y] > target) 7 y--; 8 else 9 x++; 10 } 11 return false; 12 } 13 };