boolean searchMatrix2(int[][] a, int target) {
        if (a.length == 0 || a[0].length == 0) return false;
        int col = a[0].length - 1;
        int row = 0;

        while (row < a.length && col > -1) {
            if (a[row][col] == target) return true;
            if (a[row][col] < target) row++;
            else col--;
        }
        return false;
    }
We start search the matrix from top right corner, initialize the current position to top right corner,
if the target is greater than the value in current position, then the target cannot be in entire row
of current position because the row is sorted, if the target is less than the value in current position,
then the target cannot be in the entire column because the column is sorted too. We can rule out one row or
one column each time,
so the time complexity is O(m+n).
src/problems/medium/Searcha2DMatrixII.java