All prompts are owned by LeetCode. To view the prompt, click the title link above.
First completed : June 07, 2024
Last updated : July 04, 2024
Related Topics : N/A
Acceptance Rate : Unknown
Cause funny python "1" (2) liner
class Solution:
def findMatrix(self, nums: List[int]) -> List[List[int]]:
cnt = Counter(nums)
return [[x for x in cnt if cnt.get(x) >= c] for c in range(1, max(cnt.values()) + 1)]class Solution:
def findMatrix(self, nums: List[int]) -> List[List[int]]:
cnt = Counter(nums)
maxx = max(cnt.values())
output = []
for i in range(maxx) :
output.append([])
for i in cnt :
for j in range(cnt.get(i)) :
output[j].append(i)
return output