Skip to content

Commit

Permalink
Create 1-8_Vote.py
Browse files Browse the repository at this point in the history
  • Loading branch information
jisunp04023 authored Oct 20, 2023
1 parent f622bf1 commit 5e310ac
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions 1-8_Vote.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# -*- 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)

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, "입니다.")

0 comments on commit 5e310ac

Please sign in to comment.