884. Footballers with Arrays
0
Medium
Messi and Ronaldo each have an array of integers, nums1 and nums2, respectively. Both arrays have the same length. In a single operation, they can swap the values of nums1[i] and nums2[i]. They want to determine the minimum number of operations required to make both nums1 and nums2 strictly increasing.
Input Format
The first line of input contains an integer n, representing the length of the arrays.
The second line contains the elements of nums1 (n integers separated by spaces).
The third line contains the elements of nums2 (n integers separated by spaces).
Output Format
A single integer representing the minimum number of swaps required.
The test cases are designed so that it is always possible to achieve the given input.
Example
Input
4
1 3 5 4
1 2 3 7
Output
1
Constraints
- 2 <= nums1.length <= 10^5
- nums2.length == nums1.length
- 0 <= nums1[i], nums2[i] <= 2 * 105
Loading...
View Submissions
Console