@@ -0,0 +1,1242 @@
+/**%0A * Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties:%0A *%0A * Integers in each row are sorted in ascending from left to right.%0A *%0A * Integers in each column are sorted in ascending from top to bottom.%0A *%0A * For example,%0A *%0A * Consider the following matrix:%0A *%0A * %5B %5B1,   4,  7, 11, 15%5D,%0A *   %5B2,   5,  8, 12, 19%5D,%0A *   %5B3,   6,  9, 16, 22%5D,%0A *   %5B10, 13, 14, 17, 24%5D,%0A *   %5B18, 21, 23, 26, 30%5D %5D%0A *%0A * Given target = 5, return true.%0A *%0A * Given target = 20, return false.%0A *%0A * Tags: Divide and Conquer, Binary Search%0A *%0A * Similar Problems: (M) Search a 2D Matrix%0A */%0Apublic class SearchA2DMatrix2 %7B%0A%0A    public boolean searchMatrix(int%5B%5D%5B%5D matrix, int target) %7B%0A        if (matrix == null %7C%7C matrix.length %3C 1 %7C%7C matrix%5B0%5D.length %3C 1) %7B%0A            return false;%0A        %7D%0A%0A        int row = 0;%0A        int col = matrix%5Brow%5D.length - 1;%0A%0A        while (col %3E= 0 && row %3C= matrix.length - 1) %7B%0A            if (target == matrix%5Brow%5D%5Bcol%5D) %7B%0A                return true;%0A            %7D else if (target %3C matrix%5Brow%5D%5Bcol%5D) %7B%0A                col--;%0A            %7D else if (target %3E matrix%5Brow%5D%5Bcol%5D) %7B%0A                row++;%0A            %7D%0A        %7D%0A        return false;%0A    %7D%0A%7D%0A

add 240 Search 2D Matrix 2