C++ Binary Search and Two Pointer Approach
Binary Search--->\n\n\nclass Solution {\npublic:\n    int maxDistance(vector<int>& nums1, vector<int>& nums2) {\n        int n=nums1.size();\n        int m=nums
`Binary Search--->`\n```\n\nclass Solution {\npublic:\n    int maxDistance(vector<int>& nums1, vector<int>& nums2) {\n        int n=nums1.size();\n        int m=nums2.size();\n        int maxi=INT_MIN;\n        for(int i=0;i<n;i++){\n           int l=i,h=m-1;\n            while(l<=h){\n                int mid=(l+h)/2;\n                if(nums1[i]<=nums2[mid]){\n                    maxi=max(mid-i,maxi);\n                        l=mid+1;\n                }\n                else if(nums1[i]>nums2[mid]){\n                    h=mid-1;\n                }\n                \n            }\n        }\n        return maxi==INT_MIN?0:maxi;\n    }\n};\n```\n`Two Pointers--->`\n```\nclass Solution {\npublic:\n    int maxDistance(vector<int>& nums1, vector<int>& nums2) {\n        int n=nums1.size();\n        int m=nums2.size();\n        int maxi=0;\n        int l=0,h=0;\n        while(l<n && h<m){\n            if(nums1[l]>nums2[h])    l++;\n            else {\n                    maxi=max(h-l,maxi);\n                    h++;\n            }\n                \n        }\n        \n        return maxi;\n    }\n};\n```
['Two Pointers', 'C', 'Binary Tree', 'C++']