You are viewing a single comment's thread. Return to all comments →
IN KOTLIN
fun breakingRecords(scores: Array<Int>): Array<Int> { var highestScore = Array<Int>(scores.size){0} var lowestScore = Array<Int>(scores.size){0} highestScore[0] = scores[0] lowestScore[0] = scores[0] var breakHighest = 0 var breakLowest = 0 for(i in 1 until scores.size){ if(scores[i] > highestScore[i-1]){ breakHighest++ highestScore[i] = scores[i] lowestScore[i] = lowestScore[i-1] }else if(scores[i] < lowestScore[i-1]){ breakLowest++ highestScore[i] = highestScore[i-1] lowestScore[i] = scores[i] } else { highestScore[i] = highestScore[i-1] lowestScore[i] = lowestScore[i-1] } } return arrayOf(breakHighest,breakLowest) }
Seems like cookies are disabled on this browser, please enable them to open this website
Breaking the Records
You are viewing a single comment's thread. Return to all comments →
IN KOTLIN