August 07, 2021
from collections import deque
import ast
def solution(s):
string = deque(sorted(ast.literal_eval(s.replace("{", "[").replace("}", "]")), key=lambda x:len(x)))
answer = []
while string:
if string[0][0] not in answer:
answer.append(string.popleft()[0])
else:
if len(string[0])!=0:
string[0].pop(0)
return answer
def solution(s):
s = Counter(re.findall('\d+', s))
return list(map(int, [k for k, v in sorted(s.items(), key=lambda x: x[1], reverse=True)]))
import re
from collections import Counter
def solution(s):
answer = []
s1 = s.lstrip('{').rstrip('}').split('},{')
new_s = []
for i in s1:
new_s.append(i.split(','))
new_s.sort(key = len)
for i in new_s:
for j in range(len(i)):
if int(i[j]) not in answer:
answer.append(int(i[j]))
return answer