• + 0 comments

    Swift:

    func breakingRecords(scores: [Int]) -> [Int] {
        var minScore = scores[0]
        var maxScore = scores[0]
    
        var minRecordCount = 0
        var maxRecordCount = 0
    
        for score in scores {
            if score > maxScore {
                maxScore = score
                maxRecordCount += 1
            }
    
            if score < minScore {
                minScore = score
                minRecordCount += 1
            }
        }
    
        return [maxRecordCount, minRecordCount]
    }