Notice
Recent Posts
Recent Comments
Link
250x250
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- android
- vuejs
- Vue
- BAEKJOON
- 파이썬
- 분할정복
- DFS와BFS
- 동적계획법과최단거리역추적
- AndroidStudio
- 안드로이드스튜디오
- Flutter
- DART
- 개발
- DFS
- Python
- cos pro
- django
- Algorithm
- 코테
- cos pro 1급
- 알고리즘
- 안드로이드
- 동적계획법
- codingtest
- 코드품앗이
- cos
- 백준
- issue
- C++
- 코딩테스트
Archives
- Today
- Total
Development Artist
[COS Pro 1급, Python] 1차 8번 : 누가 당선 되나요 본문
728x90
반응형
문제 유형
한줄 수정
난이도
easy
Note
1. 후보 번호 = idx
Code
# -*- coding: utf-8 -*-
# UTF-8 encoding when using korean
def solution(N, votes):
vote_counter = [0 for i in range(N+1)]
for i in votes:
vote_counter[i] += 1
max_val = max(vote_counter)
print(vote_counter)
answer = []
for idx in range(1, N + 1):
if vote_counter[idx] == max_val:
answer.append(idx)
return answer
N1 = 5
votes1 = [1,5,4,3,2,5,2,5,5,4]
ret1 = solution(N1, votes1)
print("solution 함수의 반환 값은", ret1, "입니다.")
N2 = 4
votes2 = [1, 3, 2, 3, 2]
ret2 = solution(N2, votes2)
print("solution 함수의 반환 값은", ret2, "입니다.")
※ 가끔 코드 중 print(~)가 있습니다. 정리 못한 점 죄송합니다.
728x90
반응형
'Algorithm > COS' 카테고리의 다른 글
[COS Pro 1급, Python] 1차 10번 : 주식으로 최대 수익을 내세요 (0) | 2022.02.24 |
---|---|
[COS Pro 1급, Python] 1차 9번 : 계단 게임 (0) | 2022.02.24 |
[COS Pro 1급, Python] 1차 7번 : 병합 and 정렬 (0) | 2022.02.24 |
[COS Pro 1급, Python] 1차 6번 : 체스의 나이트 (0) | 2022.02.24 |
[COS Pro 1급, Python] 1차 5번 : 소용돌이 수 (0) | 2022.02.24 |
Comments