Easy Java Solution Using Two pointers
\n\n# Code\n\nclass Solution {\n    public int maxDistance(int[] nums1, int[] nums2) {\n        int n = nums1.length;\n        int n1 = nums2.length;\n        i
\n\n# Code\n```\nclass Solution {\n    public int maxDistance(int[] nums1, int[] nums2) {\n        int n = nums1.length;\n        int n1 = nums2.length;\n        if(n == 1 && n1 == 1)\n        {\n            return 0;\n        }\n        int i = 0;\n        int j = 1;\n        int max = 0;\n        while(i < n && j < n1)\n        {\n            if(i <= j && nums1[i] <= nums2[j])\n            {\n                max = Math.max(max , j - i);\n                System.out.println(j-i);\n            }\n            else\n            {\n                while(i < n && i <= j && nums1[i] > nums2[j])\n                {\n                    i++;\n                }\n            }\n            j++;\n        }\n        return max;\n    }\n}\n```
['Java']