Two Pointer | C++ | O(n)
\nclass Solution {\npublic:\n    int maxDistance(vector<int>& nums1, vector<int>& nums2) {\n        int ans = 0;\n        for(int i = 0, j = 0; i < nums1.size()
```\nclass Solution {\npublic:\n    int maxDistance(vector<int>& nums1, vector<int>& nums2) {\n        int ans = 0;\n        for(int i = 0, j = 0; i < nums1.size() && j < nums2.size(); i++) {\n            while(j < nums2.size() && nums1[i] <= nums2[j]) j++;\n            ans = max(ans, j-i-1);\n        }\n        return ans;\n    }\n};\n```
[]