Clear C++ solution, illustrating how to use Binary Search accordingly!
bool searchMatrix(vector<vector<int>>& matrix, int target) {\n        int row = matrix.size(), col = row ? matrix[0].size() : 0;\n        int start = 0, end = r
    bool searchMatrix(vector<vector<int>>& matrix, int target) {\n        int row = matrix.size(), col = row ? matrix[0].size() : 0;\n        int start = 0, end = row, mid, endRow, startRow;\n        // first we determine the first row the target might occurs.\n        // notice that here we implement the lower_bound binary search.\n        while (start < end) {\n            mid = (start + end) / 2;\n            if (matrix[mid][col-1] >= target) {\n                end = mid;\n            } else {\n                start = mid + 1;\n            }\n        }\n        startRow = start;\n        //then we caclulate the end row (not included) the target might occurs\n        // here is for upper_bound binary search.\n        start = 0, end = row;\n        while (start < end) {\n            mid = (start + end) / 2;\n            if (matrix[mid][0] > target) {\n                end = mid;\n            } else {\n                start = mid + 1;\n            }\n        }\n        endRow = start;\n        //finally, iterate through each row until we find the target\n        // and here is also lower_bound binary search.\n        for (int i = startRow;i < endRow;++i) {\n            start = 0, end = col;\n            while (start < end) {\n                mid = (start + end) / 2;\n                if (matrix[i][mid] >= target) {\n                    end = mid;\n                } else {\n                    start = mid + 1;\n                }\n            }\n            if (start < col && matrix[i][start] == target)\n                return true;\n        }\n        return false;\n    }
['Binary Tree', 'C++']