#870
Advantage Shuffle
specialist · 805 · lc medium +31 · verified · 54.3% accepted · 1,692 likes · top 47%
Description
You are given two integer arrays nums1 and nums2 of equal length. The advantage of nums1 over nums2 is the number of indices i where nums1[i] > nums2[i].
Return any permutation of nums1 that maximizes this advantage.
Example 1:
Input: nums1 = [2,7,11,15], nums2 = [1,10,4,11]
Output: [2,11,7,15]
Example 2:
Input: nums1 = [12,24,8,32], nums2 = [13,25,32,11]
Output: [24,32,8,12]
Code
1
2
3