Java | Easy Solution with comments ✨💯
 # Intuition  \n\n\n\n\n\n# Complexity\n- Time complexity: O(m+n)\n\n\n- Space complexity: O(1)\n\n\n# Code\n\nclass Solution {\n    public boolean searchMatrix
<!-- # Intuition -->\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n<!-- # Approach -->\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity: O(m+n)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(1)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n    public boolean searchMatrix(int[][] matrix, int target) {\n        int row = 0;\n        int col = matrix[0].length-1;\n        while(row<matrix.length && col>=0){\n            if(matrix[row][col]==target) return true;\n            else if(matrix[row][col]<target) row++; //if that element is lesser than target it mean that whole row is useless\n            else col--; //if that element is greater than target it mean that column is useless \n        }\n        return false;\n    }\n}\n\n//In given example 1, it will start with 15, now 15>5 so all elements of last column will be greater than 5\n//therefore col--;\n//Now it will check 11... This way when 4 will come, 4<5 so all elements in that row will be smaller than 4\n//so row++; \n```\n![upvoteCat.png](https://assets.leetcode.com/users/images/56e36cbe-69ab-4de9-a348-7f3e59bd6171_1689406643.5026598.png)\n
['Binary Search', 'Matrix', 'Java']