def solution(s):
answer = []
s=list(s.split("{"))
# print(s)
s.sort(key = lambda x : len(x))
removed = ['', '}',","]
news = []
for ss in s :
if(len(ss)>0 and "," in ss) :
ss=list(ss.split(","))
for sss in ss :
sss=list(sss)
while removed[0] in sss :
sss.remove(removed[0])
while removed[1] in sss :
sss.remove(removed[1])
if len(sss)>0 and "".join(sss) not in news:
news.append("".join(sss))
else :
ss=list(ss)
while removed[0] in ss :
ss.remove(removed[0])
while removed[1] in ss :
ss.remove(removed[1])
if len(ss)>0 and "".join(ss) not in news:
news.append("".join(ss))
news = list((news))
for n in news :
answer.append(int(n))
return answer
def solution(s):
answer = []
s_list = s.replace("{", "").replace("}}", "").split("},")
s_list.sort(key=len)
for st in s_list:
st_li = list(map(int, st.split(',')))
for num in st_li:
if num not in answer:
answer.append(num)
return answer
s.sort(key = lambda x : len(x))
list.sort(key = lambda x : len(x))
길이기준 정렬