250x250
반응형
Recent Posts
Recent Comments
Link
«   2024/10   »
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31
Archives
Today
Total
관리 메뉴

재 현

완주하지 못한 선수 - 이름 세기 본문

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

'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