https://leetcode.com/problems/sort-array-by-increasing-frequency/description/
Sort Array by Increasing Frequency - LeetCode
Can you solve this real interview question? Sort Array by Increasing Frequency - Given an array of integers nums, sort the array in increasing order based on the frequency of the values. If multiple values have the same frequency, sort them in decreasing o
leetcode.com
1 2 3 | class Solution: def frequencySort(self, nums: List[int]) -> List[int]: return sorted(nums, key = lambda x : (nums.count(x), -x)) | cs |
반응형
'python-algorithm' 카테고리의 다른 글
leetcode 917. Reverse Only Letters (0) | 2024.01.13 |
---|---|
leetcode 1304. Find N Unique Integers Sum up to Zero (0) | 2024.01.10 |
leetcode 2278. Percentage of Letter in String (0) | 2024.01.08 |
leetcode 2500. Delete Greatest Value in Each Row (0) | 2024.01.07 |
leetcode 2706. Buy Two Chocolates (0) | 2024.01.05 |
댓글