Java Solution, 3 ms, Beats 95%
Code\n\nclass Solution {\n    public int maxDistance(int[] nums1, int[] nums2) {\n        int i = 0, j = 0, res = 0, n = nums1.length, m = nums2.length;\n      
# Code\n```\nclass Solution {\n    public int maxDistance(int[] nums1, int[] nums2) {\n        int i = 0, j = 0, res = 0, n = nums1.length, m = nums2.length;\n        while (i < n && j < m) {\n            if (nums1[i] > nums2[j]) {\n                i++;\n            }\n            else {\n                res = Math.max(res, j++ -i);\n            }\n        }\n        return res;\n    }\n}\n```
['Array', 'Two Pointers', 'Binary Search', 'Greedy', 'Java']