Short C++ O(m+n) || Well Explained
\n/*\n\tThe idea is simple start from the top right corner of the matrix \n\t1. if the target is smaller than the present element at (i,j)\n\t\t then it is also
```\n/*\n\tThe idea is simple start from the top right corner of the matrix \n\t1. if the target is smaller than the present element at (i,j)\n\t\t then it is also smaller than all the elements in the column j (because matrix is sorted coulmn wise also)\n\t\t therefore we change the coulumn i.e j--;\n\t\n\t2. else if the target is greater than the present element at (i,j)\n\t\t then it is also greater than all the elements in the row i (because matrix is sorted row wise also)\n\t\t therefore we change the row i.e i++;\n\t\n\t3. else return true because we have found the element\n\t4. otherwise return false because target is not present\n\nBELOW is the implementation of this illustration.\n\n*/\nclass Solution {\npublic:\n    bool searchMatrix(vector<vector<int>>& mat, int target) {\n        int m=mat.size(); if(m==0) return false;\n        int n=mat[0].size(),i=0,j=n-1;\n        while(i<m and j>=0)\n        {\n            if(target < mat[i][j]) j--;\n            else if(target > mat[i][j]) i++;\n            else return true;\n        }\n        return false;\n    }\n};\n```
[]