-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
134f72e
commit d6da8ae
Showing
2 changed files
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
[Programmers](<https://programmers.co.kr/learn/courses/30/lessons/42576?language=python3>). | ||
|
||
Problem : 완주하지 못한 선수 **해시** | ||
|
||
Flow : | ||
|
||
1. completion의 길이는 participant의 길이보다 1 작습니다. | ||
2. 참가자 중에는 동명이인이 있을 수 있다. | ||
|
||
|
||
|
||
Solution : | ||
|
||
1. 각 배열을 정렬한다. | ||
2. 반복문을 돌면서 각 배열의 같은 인덱스에 있는 값을 비교한다 | ||
3. 다르면 answer를 저장하고 flag를 True로 해주고 반환해준다. | ||
4. 만약 flag가 False이면 마지막의 값을 저장하고 반환해준다. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
def solution(participant, completion): | ||
participant.sort() | ||
completion.sort() | ||
answer = '' | ||
flag = False | ||
|
||
for i in range(len(completion)): | ||
if participant[i] != completion[i]: | ||
answer = participant[i] | ||
flag = True | ||
break | ||
|
||
if not flag: | ||
answer = participant[-1] | ||
|
||
return answer |