distinct, count and minOf
distinct removes duplicates, count counts matches and minBy and maxBy find extremes.
Example
val n = listOf(3, 1, 3, 2, 1)
println(n.distinct())
println(n.count { it > 1 })
println(listOf("aa", "b", "ccc").maxByOrNull { it.length })
println(n.minOrNull())Exercise
Remove duplicates.
list.()
Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.