AC clean Java solution
If we stand on the top-right corner of the matrix and look diagonally, it's kind of like a BST, we can go through this matrix to find the target like how we tra
If we stand on the top-right corner of the matrix and look diagonally, it's kind of like a BST, we can go through this matrix to find the target like how we traverse the BST.\n\n    public boolean searchMatrix(int[][] matrix, int target) {\n        if (matrix == null || matrix.length == 0 || matrix[0].length == 0)\n            return false;\n\n        int n = matrix.length, m = matrix[0].length;\n        int i = 0, j = m - 1;\n        \n        while (i < n && j >= 0) {\n            int num = matrix[i][j];\n            \n            if (num == target)\n                return true;\n            else if (num > target)\n                j--;\n            else\n                i++;\n        }\n        \n        return false;\n    }
['Java']