Clean easy solution in Java
public boolean searchMatrix(int[][] matrix, int target) {\n\t\tint line=0;\n\t\tint len=matrix.length;\n\t\tint col=matrix[0].length;\n\t\twhile (line<len && co
    public boolean searchMatrix(int[][] matrix, int target) {\n\t\tint line=0;\n\t\tint len=matrix.length;\n\t\tint col=matrix[0].length;\n\t\twhile (line<len && col>0){\n\t\t\tint num= matrix[line][col-1];\n\t\t\tif (num>target) col--;\n\t\t\tif (num<target) line++;\n\t\t\tif (num==target) return true;}\n\t\t\n        return false;\n    }\n\nThe main idea of this solution is to compare the target with the number in the top-right corner and decrease the row number or the col number one by one. It's simple and efficient.
[]