아래 블로그의 방법이 파이썬스럽고 깔끔해보인다.
https://velog.io/@jongmin97/hackerRank-ACM-ICPC-Team
def acmTeam(topic):
# Write your code here
result = [0, 0]
for i in range(len(topic) - 1):
for j in range(i + 1, len(topic)):
sum_pair = str(int(topic[i]) + int(topic[j]))
count = sum_pair.count('1') + sum_pair.count('2')
if count > result[0]:
result[0] = count
result[1] = 1
elif count == result[0]:
result[1] += 1
return result
'# 코딩 문제 관련 > 파이썬' 카테고리의 다른 글
[HackerRank-python] Queen's Attack Ⅱ (0) | 2022.08.29 |
---|---|
[HackerRank-python] Equalize the Array (0) | 2022.08.24 |
Jumping on the Clouds (0) | 2022.08.23 |
[HackerRank-python] Repeated String (0) | 2022.08.22 |
[HackerRank-python] Non-Divisible Subset (0) | 2022.08.14 |