We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent d06ad71 commit aacb0e7Copy full SHA for aacb0e7
problems/1636/jeremymanning.md
@@ -28,3 +28,21 @@ class Solution:
28

29
30
Solved!
31
+
32
+- Actually: Maybe we can save some memory by not re-storing the counts:
33
+```python
34
+class Solution:
35
+ def frequencySort(self, nums: List[int]) -> List[int]:
36
+ counts = {}
37
+ for n in nums:
38
+ if n in counts:
39
+ counts[n] += 1
40
+ else:
41
+ counts[n] = 1
42
43
+ return [n for n in sorted(nums, key=lambda x: [counts[x], -x])]
44
+```
45
46
+
47
48
+Nope, not helpful 🙃!
0 commit comments