Muhammet Emin Gündoğar
05/26/2022, 9:22 AMfun <T:Comparable<T>>linearSearch(list:List<T>, key:T):Int?{
for ((index, value) in list.withIndex()) {
if (value == key) return index
}
return null
}
I was learning linear search algorithm in kotlin but there is a thing why we used comparable interface here can you explain logic of comparable part?napperley
05/30/2022, 9:52 PM