Easy two pointer solution| JAVA | Beats 95% .
Approach\n1. Initialize both pointers as 0 at first.\n2. Add a loop unti both the pointers are equal to the length of the array.\n3. For each value of the point
# Approach\n1. Initialize both pointers as 0 at first.\n2. Add a loop unti both the pointers are equal to the length of the array.\n3. For each value of the pointer check the condition given arr[i-1] >= arr[i]\n4. If the condition statisfies then increment pointer 2 and store the difference in max;\n5. Else increment the pointer 1.\n6. Return the max value.\n# Complexity\n- Time complexity:O(N)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:O(1)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n    public int maxDistance(int[] nums1, int[] nums2) {\n        int max = 0;\n        int diff =0;\n        int p1 =0;\n        int p2 = 0;\n        while(p1<nums1.length && p2<nums2.length){\n            if(nums2[p2] >= nums1[p1]){\n                diff = p2 -p1;\n                max = Math.max(max,diff);\n                p2++;\n            }\n            else{\n                p1++;\n            }\n            \n        }\n        return max;\n    }\n}\n```
['Two Pointers', 'Java']