Description
Return any permutation of nums1 that maximizes the number of indices i where nums1[i] > nums2[i]. This is like assigning optimal matchups.
Examples
Input:
nums1 = [2,7,11,15], nums2 = [1,10,4,11]Output:
[2,11,7,15]Explanation:
Maximize advantage.
Input:
nums1 = [1], nums2 = [1]Output:
[1]Explanation:
Edge case with a single-element array.
Input:
nums1 = [3,6,7,1], nums2 = [9,5,2,8]Output:
[1,7,6,3]Explanation:
It is possible to achieve 2 advantages: 7 > 5 at index 1 and 6 > 2 at index 2. Using our smallest number (1) against the largest opponent (9) to save stronger numbers for winnable matchups.
Constraints
- •
1 ≤ nums1.length ≤ 10⁵