Created
December 25, 2019 05:07
-
-
Save toantran-ea/97d5a9aafccc14a251d595fa46dbb75e to your computer and use it in GitHub Desktop.
Kotlin Solution for Sparse Array problem
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Complete the matchingStrings function below. | |
fun matchingStrings(strings: Array<String>, queries: Array<String>): Array<Int> { | |
val result = Array<Int>(queries.size) { 0 } | |
queries.forEachIndexed { index, item -> | |
result[index] = strings.count { item == it } | |
} | |
return result | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment