일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- list.sorted()
- COUNT
- Boto3
- Python
- string
- homebrew-core is a shallow clone.
- 알고리즘 풀이
- sting position
- List to String
- Python 나머지
- sort()
- 피보나치 수
- Split
- 프로그래머스
- zip()
- set to list
- 알고리즘
- Python 몫
- List 초기화
- permutations
- List
- Modified Date
- cask
- python3
- index
- RecursionError
- list to set
- Unknown command: cask
- Algorithm
- list.pop(0)
- Today
- Total
데이터와 코드로 세상을 바라봅니다.
[Python 3] - List, sorted(), pop(), index() 본문
[풀이 코드]
def solution(participant, completion):
answer = ''
participant=sorted(participant)
completion=sorted(completion)
answer = participant[len(completion)]
for i in range(0,len(completion)):
if participant[i]!=completion[i]:
answer=participant[i]
break
return answer
def solution(participant, completion):
answer = ''
for i in range(0, len(completion)) :
index_pos = participant.index(completion[i])
participant.pop(index_pos)
answer = participant.pop()
return answer
[문제] - 완주하지 못한 선수
[문제 설명]
수많은 마라톤 선수들이 마라톤에 참여하였습니다. 단 한 명의 선수를 제외하고는 모든 선수가 마라톤을 완주하였습니다.
마라톤에 참여한 선수들의 이름이 담긴 배열 participant와 완주한 선수들의 이름이 담긴 배열 completion이 주어질 때, 완주하지 못한 선수의 이름을 return 하도록 solution 함수를 작성해주세요.
제한사항
- 마라톤 경기에 참여한 선수의 수는 1명 이상 100,000명 이하입니다.
- completion의 길이는 participant의 길이보다 1 작습니다.
- 참가자의 이름은 1개 이상 20개 이하의 알파벳 소문자로 이루어져 있습니다.
- 참가자 중에는 동명이인이 있을 수 있습니다.
입출력 예
participantcompletionreturn
[leo, kiki, eden] | [eden, kiki] | leo |
[marina, josipa, nikola, vinko, filipa] | [josipa, filipa, marina, nikola] | vinko |
[mislav, stanko, mislav, ana] | [stanko, ana, mislav] | mislav |
[참고 자료]
Check if a Python list item contains a string inside another string
I have a list: my_list = ['abc-123', 'def-456', 'ghi-789', 'abc-456'] and want to search for items that contain the string 'abc'. How can I do that? if 'abc' in my_list: would check if 'abc' ex...
stackoverflow.com
www.geeksforgeeks.org/python-list-pop/
Python list | pop() - GeeksforGeeks
A Computer Science portal for geeks. It contains well written, well thought and well explained computer science and programming articles, quizzes and practice/competitive programming/company interview Questions.
www.geeksforgeeks.org
stackoverflow.com/questions/14849293/python-find-index-position-in-list-based-of-partial-string
python - find index position in list based of partial string
mylist = ["aa123", "bb2322", "aa354", "cc332", "ab334", "333aa"] I need the index position of all items that contain 'aa'. I'm having trouble combining enumerate() with partial string matching. I'...
stackoverflow.com
thispointer.com/python-how-to-find-all-indexes-of-an-item-in-a-list/
Python: Find index of element in List (First, last or all occurrences) – thispointer.com
In this article we will discuss different ways to get index of element in list in python. We will see how to find first index of item in list, then how to find last index of item in list, or then how to get indices of all occurrences of an item in the list
thispointer.com
'Code > Python' 카테고리의 다른 글
[Python3] - String reverse, String split (0) | 2020.11.18 |
---|---|
[Python3] - String, index, concat, add (0) | 2020.11.16 |
[Python 3] - list(), stack concept, pop(), len(), append() (0) | 2020.11.09 |
[Python 3] - String, Upper(), Lower(), Count(), Contain() (0) | 2020.11.05 |
[Python 3] - Dictionary, Key, Value, Max, Min, Sort, Desc (0) | 2020.11.04 |