Leetcode 870. Advantage Shuffle
2023-03-28 11:38 作者:您是打尖儿还是住店呢 | 我要投稿
You are given two integer arrays nums1 and nums2 both of the same length. The advantage of nums1 with respect to nums2 is the number of indices i for which nums1[i] > nums2[i].
Return any permutation of nums1 that maximizes its advantage with respect to nums2.
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]
Constraints:
1 <= nums1.length <= 105nums2.length == nums1.length0 <= nums1[i], nums2[i] <= 109再次认识treemap
Runtime: 271 ms, faster than 5.06% of Java online submissions for Advantage Shuffle.
Memory Usage: 60.8 MB, less than 60.34% of Java online submissions for Advantage Shuffle.

