재 현
완주하지 못한 선수 - 이름 세기 본문
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
'Coding test' 카테고리의 다른 글
BOJ [11724번]: 연결 요소의 개수 (0) | 2020.11.02 |
---|---|
[프로그래머스] 시저암호 (0) | 2020.11.02 |
BOJ [1931번] : 회의실 배정 (0) | 2020.10.30 |
BOJ [11047번]: 동전 0 (0) | 2020.10.30 |
전화번호 목록 (0) | 2020.10.30 |