[Python/C++] 2 Pointers - O(n)
Python3 \n\nclass Solution(object):\n\tdef maxDistance(self, nums1, nums2):\n\t\tresult = 0\n\t\ti, j = 0, 0\n\t\tn1,n2 = len(nums1), len(nums2)\n\t\t\n\t\twhil
1. Python3 \n```\nclass Solution(object):\n\tdef maxDistance(self, nums1, nums2):\n\t\tresult = 0\n\t\ti, j = 0, 0\n\t\tn1,n2 = len(nums1), len(nums2)\n\t\t\n\t\twhile i < n1 and j < n2:\n\t\t\tif nums1[i] <= nums2[j]:\n\t\t\t\tresult = max(result, j-i)\n\t\t\t\tj += 1\n\t\t\telse:\n\t\t\t\ti += 1\n\t\t\t\tj += 1\n\t\treturn result\n```\n\n2. C++\n```\nint maxDistance(vector<int>& nums1, vector<int>& nums2) {\n        int i = 0, j = 0, result = 0, n1 = nums1.size(), n2 = nums2.size();\n        while (i < n1 && j < n2) {\n            if (nums1[i] <= nums2[j]){\n                 result = max(result, j - i);\n\t\t\t\t j++;\n\t\t\t\t }\n            else{\n\t\t\t\ti++;\n\t\t\t\tj++;\n\t\t\t}   \n        }\n        return result;\n    }\n```
[]