본문 바로가기

알고리즘/해커랭크

Breaking the Records

문제

https://www.hackerrank.com/challenges/breaking-best-and-worst-records/problem?h_r=next-challenge&h_v=zen

 

각 시즌별 점수가 주어졌을 때 최고/최저 기록 갱신횟수 출력

 

입력 예시

9
10 5 20 20 4 5 2 25 1

출력 예시

2 4

 

제출한 코드

def breakingRecords(scores):
    maxS, minS = scores[0], scores[0]
    res=[]
    x, y = 0, 0
    for i in scores:
        if i > maxS:
            x+=1
            maxS=i
        if i < minS:
            y+=1
            minS=i
    res.append(x)
    res.append(y)
    return res

 

 

'알고리즘 > 해커랭크' 카테고리의 다른 글

Divisible Sum Pairs  (0) 2020.03.08
Birthday Chocolate  (0) 2020.03.08
Between Two Sets  (0) 2020.03.07
Kangaroo  (0) 2020.03.06
Apple and Orange  (0) 2020.03.06