Sparse Arrays

  • + 0 comments
    fun matchingStrings(strings: Array<String>, queries: Array<String>): Array<Int> {
            val resultArray = Array(queries.size){0}
            queries.forEachIndexed { index, element ->
                resultArray[index] = strings.count { it == element }
            }
            return resultArray
    }