Skip to content

Commit

Permalink
made tailrec
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxet1000 committed Jul 20, 2024
1 parent e7c3de8 commit e51f32d
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ class ScoreList {
values: IntArray,
firstIndexCurrentInterval: Int,
lastIndexCurrentInterval: Int,
numberOfSkipsIntermediate: Int = 0
nbSkipsIntermedSol: Int = 0
): Int {
if (lastIndexCurrentInterval < firstIndexCurrentInterval) return numberOfSkipsIntermediate
if (lastIndexCurrentInterval < firstIndexCurrentInterval) return nbSkipsIntermedSol
var nbOfSkips = 0
var nextLastIndex = lastIndexCurrentInterval
for (i in firstIndexCurrentInterval..lastIndexCurrentInterval) {
Expand All @@ -84,7 +84,7 @@ class ScoreList {
if (lastIndexCurrentInterval + nbOfSkips < values.size) nextLastIndex++
}
}
return getNumberOfSkipsByInterval(values, lastIndexCurrentInterval + 1, nextLastIndex, nbOfSkips)
return getNumberOfSkipsByInterval(values, lastIndexCurrentInterval + 1, nextLastIndex, nbSkipsIntermedSol + nbOfSkips)
}

/**
Expand Down

0 comments on commit e51f32d

Please sign in to comment.