You are viewing a single comment's thread. Return to all comments →
Kotlin O(M +N) in 2 lines
fun matchingStrings(strings: Array, queries: Array): Array { val occ = strings.groupingBy { it }.eachCount() return queries.map { occ[it] ?: 0 }.toTypedArray() }
Seems like cookies are disabled on this browser, please enable them to open this website
Sparse Arrays
You are viewing a single comment's thread. Return to all comments →
Kotlin O(M +N) in 2 lines