Coding test
완주하지 못한 선수 - 이름 세기
본명은이점례
2020. 10. 30. 14:59
728x90
- 이름에 대해서 어떤 수를 기록하고 저장할 수 있는 구조
- 이름 대신 번호가 주어졌다면 ->배열
- 문자열로 원소를 찾아갈 수 있는 구조 -> 해시
1.
d = {}
for x in participants:
d[x] = d.get(x,0)+1
for y in completion:
d[x] -= 1
idx = list[k for k,v in d.items() if v>0]
answer = idx
2.
participants.sort()
completion.sort()
for i in range(len(participants))
if participants[i] in completion[i]:
return participants[i]
3.
answer = collections.counter(participants) - collections.counter(completion)
list(answer.keys())[0]
728x90