본문 바로가기
HackerRank Algorithm

[HackerRank] 18. Breaking the Records

by KIha_Jung 2020. 4. 1.

Breaking the Records

import math
import os
import random
import re
import sys

# Complete the breakingRecords function below.
def breakingRecords(scores):
    max_score = scores[0]
    min_score = scores[0]
    max_count = 0
    min_count = 0
    
    for score in scores:
        if max_score < score:
            max_score = score
            max_count += 1
        elif min_score > score:
            min_score = score
            min_count += 1
    return max_count, min_count

if __name__ == '__main__':
    n = int(input())
    scores = list(map(int, input().rstrip().split()))
    
    result = breakingRecords(scores)
    print(result[0], result[1])

댓글