C++ O(N) Easy Solution Using two pointers
\nclass Solution {\npublic:\n    int maxDistance(vector<int>& nums1, vector<int>& nums2) {\n        int i=0,j=0;\n        int n=nums1.size(),m=nums2.size();\n  
```\nclass Solution {\npublic:\n    int maxDistance(vector<int>& nums1, vector<int>& nums2) {\n        int i=0,j=0;\n        int n=nums1.size(),m=nums2.size();\n        int ans=0;\n        while(i<n && j<m)\n        {\n            if(nums1[i]<=nums2[j]) \n            {\n                ans=max(j-i,ans);\n                j++;\n            }\n            else\n            {\n                i++;\n            }\n        }\n        return ans;\n    }\n};\n```
['Two Pointers', 'C']