728x90
반응형
문제 링크 : https://www.hackerrank.com/challenges/breaking-best-and-worst-records/problem
Breaking the Records | HackerRank
Given an array of Maria's basketball scores all season, determine the number of times she breaks her best and worst records.
www.hackerrank.com
최고기록을 갱신 시마다 업데이트 시켜주는 것이 중요하다는 것을 알게 되었습니다.
def breakingRecords(scores):
# Write your code here
win_cnt, lose_cnt = 0,0
breaking_win,breaking_lose = scores[0],scores[0]
for i in range(1,len(scores)):
if scores[i] > breaking_win:
win_cnt += 1
breaking_win = scores[i]
if scores[i] < breaking_lose:
lose_cnt += 1
breaking_lose = scores[i]
return win_cnt, lose_cnt
728x90
반응형
'알고리즘' 카테고리의 다른 글
[알고리즘] 강의 중간 정리 with Java (0) | 2022.04.12 |
---|---|
[트리] 전위순회, 중위순회, 후위순회 (0) | 2022.04.11 |
[알고리즘] 퀵 소트 공부해보기 (0) | 2021.11.13 |
[프로그래머스] 가장 긴 펠린드롬 (0) | 2021.11.08 |
[HackerRank] Divisible Sum Pairs (PYTHON) (0) | 2021.11.01 |