classSolution { public: boolsearchMatrix(vector<vector<int>> &matrix, int target){ int m = matrix.size(), n = matrix[0].size(); int x = 0, y = n - 1; while (x < m && y > -1) { if (matrix[x][y] < target) { ++x; } elseif (matrix[x][y] > target) { --y; } else { returntrue; } } returnfalse; } };