public static boolean searchMatrix(int[][] matrix, int target) {
    if (matrix == null || matrix.length == 0 || matrix[0].length == 0)
      return false;
    if (target < matrix[0][0])
      return false;
    int row = search(matrix, target);
    int i = 0;
    int j = matrix[row].length - 1;
    while (i <= j) {
      int mid = (i + j) / 2;
      if (matrix[row][mid] == target) {
        return true;
      } else if (matrix[row][mid] < target) {
        i = mid + 1;
      } else {
        j = mid - 1;
      }
    }
    return false;
  }