[F] Fix index out of bounds

pull/20/head
Azalea 2024-03-05 03:22:53 -05:00
parent f3090870be
commit ff9358b986
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.sortedBy { it.date }.toList()
if (d.isEmpty()) return listOf()
// Precompute the play counts for each date in O(n)
val playCounts = d.groupingBy { it.date }.eachCount()