#3774
Absolute Difference Between Maximum and Minimum K Elements
easy · 75.4% accepted · 38 likes · top 86%
Description
You are given an integer array nums and an integer k.
Find the absolute difference between:
- the sum of the k largest elements in the array; and
- the sum of the k smallest elements in the array.
Return an integer denoting this difference.
Solution