O(m+n) Java solution
    public boolean searchMatrix(int[][] matrix, int target) {\n        int m = matrix.length;\n        int n = matrix[0].length;\n        int x = 0;\n        in
        public boolean searchMatrix(int[][] matrix, int target) {\n        int m = matrix.length;\n        int n = matrix[0].length;\n        int x = 0;\n        int y = n - 1;\n        while (x < m && y >= 0) {\n            if (target == matrix[x][y]) {\n                return true;\n            } else if (target > matrix[x][y]) {\n                x++;\n            } else {\n                y--;\n            }\n        }\n        return false;\n    }
[]