✔️Python, C++,Java|| Beginner level ||As Simple As U Think||Simple-Short-Solution✔️
Please upvote to motivate me in my quest of documenting all leetcode solutions. HAPPY CODING:)\nAny suggestions and improvements are always welcome.\n___\n__\nQ
***Please upvote to motivate me in my quest of documenting all leetcode solutions. HAPPY CODING:)\nAny suggestions and improvements are always welcome*.**\n___________________\n_________________\n***Q1855. Maximum Distance Between a Pair of Values***\nYou are given two non-increasing 0-indexed integer arrays nums1 and nums2.\n\nA pair of indices` (i, j`), where` 0 <= i < nums1.length` and` 0 <= j < nums2.length`, is valid if both` i <= j` and `nums1[i] <= nums2[j]`. The distance of the pair is `j - i`.\n\nReturn the maximum distance of any valid `pair (i, j)`. If there are no valid pairs, return 0.\n\nAn array arr is non-increasing if `arr[i-1] >= arr[i]` for every` 1 <= i < arr.length`.\n____________________________________________________________________________________________________________________\n____________________________________________________________________________________________________________________\n\u2705 **Python  Code** :\n```\nclass Solution:\n    def maxDistance(self, nums1: List[int], nums2: List[int]) -> int:\n        i,j,n,m,res=0,0,len(nums1),len(nums2),0\n        while i<n and j<m:\n            if nums1[i]>nums2[j]:\n                i+=1\n            else:\n                res=max(res,j-i)\n                j+=1\n        return res\n```\n**Runtime:**  1627 ms\t\n**Memory Usage:**  31.1 MB\t\n____________________________________________________________________________________________________________________\n____________________________________________________________________________________________________________________\n\n\u2705 **Java 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        {\n            if(nums1[i]>nums2[j])\n                i++;\n            else\n                res=Math.max(res,j++-i);\n        }\n        return res;   \n    }\n}\n```\n**Runtime:**  2 ms\t\n**Memory Usage:**  48.6 MB\n____________________________________________________________________________________________________________________\n____________________________________________________________________________________________________________________\n\u2705 **C++  Code** :\n```\nclass Solution {\npublic:\n    int maxDistance(vector<int>& nums1, vector<int>& nums2) {\n        int i=0,j=0,res=0,n=nums1.size(),m=nums2.size();\n        while(i<n && j<m)\n        {\n            if(nums1[i]>nums2[j])\n                i++;\n            else\n                res=max(res,j++-i);\n        }\n        return res;\n    }\n};\n```\n**Runtime:**  325 ms\t\n**Memory Usage:**  98.5 MB\t\t\n____________________________________________________________________________________________________________________\n____________________________________________________________________________________________________________________\n\nIf you like the solution, please upvote \uD83D\uDD3C\nFor any questions, or discussions, comment below. \uD83D\uDC47\uFE0F\n
['C', 'Binary Tree', 'Python', 'Java']