File tree Expand file tree Collapse file tree 1 file changed +41
-0
lines changed Expand file tree Collapse file tree 1 file changed +41
-0
lines changed Original file line number Diff line number Diff line change 1+ # https://www.hackerrank.com/challenges/breaking-best-and-worst-records/problem
2+
3+
4+ #!/bin/python3
5+
6+ import os
7+ import sys
8+
9+ #
10+ # Complete the breakingRecords function below.
11+ #
12+ def breakingRecords (score ):
13+ nb_best_score_increased = 0
14+ nb_worst_score_decreased = 0
15+ max_score = score [0 ]
16+ min_score = score [0 ]
17+
18+ for i in range (1 , len (score )):
19+ if score [i ] > max_score :
20+ nb_best_score_increased += 1
21+ max_score = score [i ]
22+ if score [i ] < min_score :
23+ nb_worst_score_decreased += 1
24+ min_score = score [i ]
25+
26+ return [nb_best_score_increased , nb_worst_score_decreased ]
27+
28+
29+ if __name__ == '__main__' :
30+ f = open (os .environ ['OUTPUT_PATH' ], 'w' )
31+
32+ n = int (input ())
33+
34+ score = list (map (int , input ().rstrip ().split ()))
35+
36+ result = breakingRecords (score )
37+
38+ f .write (' ' .join (map (str , result )))
39+ f .write ('\n ' )
40+
41+ f .close ()
You can’t perform that action at this time.
0 commit comments