Breaking the Records

Breaking the Records | HackerRank

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
function breakingRecords(scores: number[]): number[] {
// Write your code here
let minRecord = scores[0]
let maxRecord = scores[0]
let minCount = 0
let maxCount = 0
for(let i =0;i<scores.length;i++){
if(scores[i] > maxRecord){
maxRecord = scores[i]
maxCount ++
} else if(scores[i] < minRecord){
minRecord = scores[i]
minCount++
}
}
return [maxCount,minCount]
}