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)


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