Skip to content

Commit

Permalink
60.py
Browse files Browse the repository at this point in the history
  • Loading branch information
huisuu committed Aug 28, 2024
1 parent 296435f commit feb57f7
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions HSKIM/51to60/60.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
def solution(s):
# 문자열에서 양쪽의 "{{"와 "}}"를 제거하고, 중괄호를 기준으로 split
s = s[2:-2].split("},{")

# 각 요소를 리스트로 변환
arr = [list(map(int, x.split(','))) for x in s]

# 길이 기준으로 오름차순 정렬
arr.sort(key=len)

answer = []
for subset in arr:
for num in subset:
if num not in answer:
answer.append(num)
break

return answer

s = "{{1,2,3},{2,1},{1,2,4,3},{2}}"
print(solution(s))

0 comments on commit feb57f7

Please sign in to comment.