Tap here to switch tabs
Problem
Submissions

Problem: Advantage Shuffle

med
30 min
Try to solve the Advantage Shuffle problem.

Statement

You are given two integer arrays, nums1 and nums2, both of the same length.

The advantage of nums1 with respect to nums2 is defined as the total number of indices i such that nums1[i] > nums2[i].

Return any permutation of nums1 that maximizes its advantage with respect to nums2.

Constraints:

  • 1≤1 \leq nums1.length ≤105\leq 10^5

  • nums2.length ==== nums1.length

  • 0≤0 \leq nums1[i], nums2[i] ≤109\leq 10^9

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Advantage Shuffle

med
30 min
Try to solve the Advantage Shuffle problem.

Statement

You are given two integer arrays, nums1 and nums2, both of the same length.

The advantage of nums1 with respect to nums2 is defined as the total number of indices i such that nums1[i] > nums2[i].

Return any permutation of nums1 that maximizes its advantage with respect to nums2.

Constraints:

  • 1≤1 \leq nums1.length ≤105\leq 10^5

  • nums2.length ==== nums1.length

  • 0≤0 \leq nums1[i], nums2[i] ≤109\leq 10^9