Skip to content

Commit d4d3b82

Browse files
Merge pull request #2174 from CodingTestStudy2/최원준
[최원준] 2026/10/14
2 parents 0ab90da + 90c7eec commit d4d3b82

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
class Solution:
2+
def rearrangeArray(self, nums: list[int]) -> list[int]:
3+
n = len(nums)
4+
visited = set()
5+
ans = []
6+
7+
while len(visited) != n:
8+
9+
candids = set()
10+
for i in range(n):
11+
if i in visited:
12+
continue
13+
if nums[i] in candids:
14+
continue
15+
visited.add(i)
16+
candids.add(nums[i])
17+
18+
temp = []
19+
for num in candids:
20+
temp.append(num)
21+
temp.sort()
22+
for num in temp:
23+
ans.append(num)
24+
25+
return ans
26+

0 commit comments

Comments
 (0)