JAVA 2 Pointer
CODE:\n\n    public int maxDistance(int[] nums1, int[] nums2) {\n        int i=0 , j=0;\n        int result=0;\n        while(i<nums1.length && j<nums2.length){
**CODE:**\n```\n    public int maxDistance(int[] nums1, int[] nums2) {\n        int i=0 , j=0;\n        int result=0;\n        while(i<nums1.length && j<nums2.length){\n            if(nums1[i]>nums2[j]){\n                i++;\n            }else{\n                result=Math.max(j-i,result);  //if(j<i  , j-i will be negative and result will not get updated \n                j++;\n           }\n        }\n        return result;\n}\n```\n\n**Complexity:**\n`Time:O(maximum(n,m)) and Space:O(1)`\n\n
['Two Pointers', 'Java']