Practice Maximum Distance Between a Pair of Values
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
You are given two non-increasing 0-indexed integer arrays nums1 and nums2. A 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. Return the maximum distance of any valid pair (i, j). If there are no valid pairs, return 0. An array arr is non-increasing if arr[i-1] >= arr[i] for every 1 <= i < arr.length.
Source: Maximum Distance Between a Pair of Values on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
nums1 = [55,30,5,4,2], nums2 = [100,20,10,10,5]
2
# Example 2
nums1 = [2,2,2], nums2 = [10,10,1]
1
# Example 3
nums1 = [30,29,19,5], nums2 = [25,25,25,25,25]
2
Constraints
Related LeetCode Problems
Practice more problems similar to Maximum Distance Between a Pair of Values.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.