Share my C++  O(m+n) solution,easy to understand
class Solution {\n    public:\n        bool searchMatrix(vector<vector<int>>& matrix, int target) {\n            int row = matrix.size();\n            if (row =
    class Solution {\n    public:\n        bool searchMatrix(vector<vector<int>>& matrix, int target) {\n            int row = matrix.size();\n            if (row == 0)\n                return false;\n            int col = matrix[0].size();\n            if (col == 0)\n                return false;\n            if (target < matrix[0][0] || target > matrix[row-1][col-1])\n                return false;\n            \n            int i = 0, j = col - 1;\n            while (i < row && j >=0)\n            {\n                if (target == matrix[i][j])\n                    return true;\n                //if target > matrix[i][j],then target must not appear in row-i\n                else if (target > matrix[i][j])\n                    ++i;\n                //if target < matrix[i][j],then target must not appear in column-j\n                else\n                    --j;\n            }\n            \n            return false;\n        }\n    };
['C++']