[Java] All approach - Regular and Modified Binary Search comment explained
Regular Binary Search - O(m * logn)\n\nclass Solution {\n    public boolean searchMatrix(int[][] matrix, int target) {\n        for (int i=0;i<matrix.length;i++
**Regular Binary Search - O(m * logn)**\n```\nclass Solution {\n    public boolean searchMatrix(int[][] matrix, int target) {\n        for (int i=0;i<matrix.length;i++){\n                int left  = 0;\n                int right = matrix[i].length-1;\n                while (left <= right){\n                        int cMid = left + (right - left) / 2; // find mid\n                        if (matrix[i][cMid] == target) return true; // if target matches then return true\n                        else if (matrix[i][cMid] < target) left = cMid+1; // if the value is less than target then increment the left pointer\n                        else right = cMid-1; // otherwise decrement the right pointer\n                } \n        }\n        return false;\n    }\n}\n```\n**Modified Binary Search - O(m + n)**\n```\nclass Solution {\n    public boolean searchMatrix(int[][] matrix, int target) {\n        int row = matrix.length;\n        int col = matrix[0].length;\n        \n        int i = 0;\n        int j = col-1;\n        while (i < row && j >= 0){\n            if (matrix[i][j] == target) return true;\n            else if (matrix[i][j] < target) i++; //everything in the previous row will be lesser so increment row pointer\n            else j--;    //everything from the column will be greater so decrement the column pointer\n        }\n        return false;\n    }\n}\n```
['Binary Tree', 'Java']