USING TWO POINTER ALGORITHM
\nclass Solution {\npublic:\n    bool searchMatrix(vector<vector<int>>& matrix, int target) {\n         int n=matrix.size();\n        int m=matrix[0].size()-1;\
```\nclass Solution {\npublic:\n    bool searchMatrix(vector<vector<int>>& matrix, int target) {\n         int n=matrix.size();\n        int m=matrix[0].size()-1;\n        int i=0;\n        int j=m;\n        while(i<n&&j>=0)\n        {\n            if(matrix[i][j]==target) // RETURN TRUE IF TARGET GOT FOUND\n            return true;\n            else if(matrix[i][j]>target)\n            {\n                j--;\n            }\n            else \n            {\n                i++;\n            }\n        }\n        \n        return false; // TARGET IS NOT PRESENT.SO RETURN FALSE\n    }\n};\n```\n**TIME COMPLEXITY;-O(M+N)**\n**SPACE COMPLEXITY:-O(1)**
[]