JAVA: 3 solutions : Maximum Distance Between a Pair of Values
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n     O(n^2) --> O( maximum(n,m) ) --> O(nlogn)\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n    O(1)\n\n# Code\n```\nclass Solution {\n    public int maxDistance(int[] nums1, int[] nums2) {\n\n        // int diff=0;\n        // for(int i=0 ;i<nums1.length; i++){\n        //     for(int j=i;j<nums2.length;j++){\n        //      if(nums1[i]<=nums2[j] && i<=j){\n        //         diff=Math.max(diff,(j-i));\n        //      }\n        //     }\n        // }\n        // return diff;\n\n//-----------------------------------------------------------\n\n        // int i=0;\n        // int j=0;\n        // int res=0;\n        // while(i<nums1.length && j<nums2.length ){\n        //     if(nums1[i]>nums2[j]){\n        //         i++;\n        //     }else{\n        //         res=Math.max(res,(j-i));\n        //         j++;\n        //     }\n        // }\n        // return res;\n\n//-----------------------------------------------------------\n\n    int d = 0;\n        for(int i=0;i<nums1.length;i++){\n            int start = i;\n            int end = nums2.length-1;\n            while(start <= end){\n                int mid = start +  (end-start)/2;\n                if(nums1[i] <= nums2[mid]){\n                    d = Math.max(d,mid-i);\n                    start = mid+1;\n                } else {\n                    end = mid-1;\n                }\n            }\n        }\n        return d;\n\n\n    }\n}\n```
['Two Pointers', 'Binary Search', 'Java']