1471. The k Strongest Values in an Array
Содержание
class Solution:
def getStrongest(self, arr: List[int], k: int) -> List[int]:
arr.sort()
m = arr[(len(arr) - 1) >> 1]
arr.sort(key=lambda x: (-abs(x - m), -x))
return arr[:k]