Preview:
class Solution
{
    public:
    //Function to search a given number in row-column sorted matrix.
    bool search(vector<vector<int> > matrix, int n, int m, int x) 
    {
        int long long i=0,j=m-1;
        while(i<n && j>=0&& j<n&&i>=0)
        {
            if(matrix[i][j]==x) return 1;
            else if(matrix[i][j]>=x) j--;
            else i++;
        }
        return 0;
    }
};
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter