public class Solution {
    public boolean searchMatrix(int[][] matrix, int target) {
        if (matrix == null || matrix.length == 0) return false;
        int m = matrix.length, n = matrix[0].length;
        int up = 0;
        int down = m - 1;
        int left = 0;
        int right = n;

        //二分查找所在行
        while (up < down){
            int mid = (down + up)/2;
            if(matrix[mid][n-1] > target) down = mid;
            else if(matrix[mid][n-1] < target) up = mid+1;
            else return true;
        }

        //二分查找所在列
        while (left < right){
            int mid = (left + right) / 2;
            if (matrix[up][mid] > target) right = mid;
            else if(matrix[up][mid] < target) left = mid + 1;
            else return true;
        }
        return false;
    }

    public static void main(String[] args) {
        int[][] matrix = new int[][]{{1,3,5,7}, {10,11,16,20}, {23,30,34,50}};
        Solution solution = new Solution();
        System.out.println(solution.searchMatrix(matrix, 3));
    }
}

@@ -286,16 +286,39 @@
 ght = n;
+ //%E5%AD%98%E5%9C%A8%E5%8F%AA%E6%9C%89%E4%B8%80%E5%88%97%E7%9A%84%E6%83%85%E5%86%B5%EF%BC%8C%E6%89%80%E4%BB%A5%E8%BF%99%E5%9D%97%E4%B8%8D%E8%83%BD%E4%B8%BAn-1
 %0A%0A      

add comment for problem 74