Analyzing the algorithmic complexity of the Kotlin API’s distinctBy function

Applying an algorithm in real life

Filtering the list with a loop

fun filterList(products: List): List {
val newList = emptyList()
products.forEach { product ->
if(findProduct(products, product) == false) {
return newList

fun findProduct(list: List, productToFind: Product): Boolean {
list.forEach { product ->
if( == {
return true
return false

Filtering the list with the distinctBy function

val newList = products.distinctBy { product -> product.code }




Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store