Sponsored
Sponsored
Use these hints if you're stuck. Try solving on your own first.
Think about how to check that performing k operations is possible.
To perform k operations, it’s optimal to use the smallest k elements and the largest k elements and think about how to match them.
It’s optimal to match the ith smallest number with the k-i + 1 largest number.
Now we need to binary search on the answer and find the greatest possible valid k.