Skip to content Skip to sidebar Skip to footer

Find Last Occurrence Index Value Of Inner List And Outer List In Efficient Way In Kotlin

Hey i have nested list and i wanted to find last occurrence index value of inner list and outer list. I tried to search Find last occurrence of a String in array using Kotlin. How

Solution 1:

You can use indexOfLast and indexOfFirst functions for this

var innerIndex = -1
val outerIndex: Int = value.indexOfLast{ group ->
    innerIndex = group.value.indexOfFirst { groupValue -> groupValue != null && groupValue.isRead != true }
    return@indexOfLast innerIndex != -1
}

if(outerIndex != -1) {
    // match found 
}

Post a Comment for "Find Last Occurrence Index Value Of Inner List And Outer List In Efficient Way In Kotlin"