1
import heapq
2

3

4
class Solution:
5
def sortArray(self, nums: List[int]) -> List[int]:
6

7
h = {}
8
for i in nums:
9
if i in h:
10
h[i] += 1
11
else:
12
h[i] = 1
13

14
heap = []
15
for i in h:
16
heap.append([i, h[i]])
17

18
heapq.heapify(heap)
19
ans = []
20

21
while heap:
22
x = heapq.heappop(heap)
23
ans.append(x[0])
24
if x[1] > 1:
25
heapq.heappush(heap, [x[0], x[1] - 1])
26

27
return ans

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0