Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 48af27b

Browse files
Create 2610.py
1 parent 40b9319 commit 48af27b

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

‎2501-3000/2610.py‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
from collections import defaultdict
2+
3+
class Solution:
4+
def findMatrix(self, nums: List[int]) -> List[List[int]]:
5+
d = defaultdict(int)
6+
for num in nums:
7+
d[num]+=1
8+
res = []
9+
while d:
10+
row = []
11+
keys = list(d.keys())
12+
for k in keys:
13+
row.append(k)
14+
d[k]-=1
15+
if d[k]==0:
16+
del d[k]
17+
res.append(row)
18+
return res
19+

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /