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