90% TIME AND 80% SPACE BEATS || C++ || SIMPLE || TIME O(n+m)
\nclass Solution {\npublic:\n    int maxDistance(vector<int>& nums1, vector<int>& nums2) {\n        int n1 = nums1.size(),n2 = nums2.size(),ans = 0;\n        in
```\nclass Solution {\npublic:\n    int maxDistance(vector<int>& nums1, vector<int>& nums2) {\n        int n1 = nums1.size(),n2 = nums2.size(),ans = 0;\n        int i = n1-1,j = n2-1;\n        while(j>=0 && nums2[j]<nums1[i]){\n            j--;\n        }\n        // cout<<1;\n        while(j>=0){\n            while(i>=0 && nums1[i]<=nums2[j]){\n                i--;\n            }\n            ans = max(j-i-1,ans);\n            j--;\n        }\n        return ans;\n    }\n};\n```
['Two Pointers', 'C', 'C++']