C++ || Easy ✅ || Two-Pointers✅ || Shortest and Fast 🔥
\nclass Solution {\npublic:\n    int maxDistance(vector<int>& nums1, vector<int>& nums2) {\n        int ans = 0;\n        int n = nums1.size(), m = nums2.size()
```\nclass Solution {\npublic:\n    int maxDistance(vector<int>& nums1, vector<int>& nums2) {\n        int ans = 0;\n        int n = nums1.size(), m = nums2.size();\n        int i = n-1;\n        \n        for(int j = m - 1; j>=ans; j--){\n            while(i>=0 && nums1[i] <= nums2[j])\n                i--;\n            \n            if(i<n-1 && nums1[i+1] <= nums2[j])\n                ans = max(ans, j-i-1);\n        }\n        \n        return ans;\n    }\n};\n```
['Two Pointers', 'C']