[F] Fix out of bounds

pull/17/head
Azalea 2024-03-03 17:09:55 -05:00
parent ef5d0a81eb
commit b333045d41
1 changed files with 1 additions and 0 deletions

View File

@ -25,6 +25,7 @@ fun findTrend(log: List<TrendLog>): List<TrendOut> {
// O(n log n)
val d = log.filter { it.date >= minDate }.sortedBy { it.date }.toList()
if (d.isEmpty()) return emptyList()
// Precompute the play counts for each date in O(n)
val playCounts = d.groupingBy { it.date }.eachCount()