Kotlin arrays

Report a typo

Write code that prints the third row of the inputArray in one string. The elements should be separated by a comma.

It is guaranteed that inputArray is already initialized and contains at least 3 nested arrays.

Tip: Use the joinToString() function.

Sample Input 1:

val inputArray = arrayOf(
    arrayOf(1, 2, 3),
    arrayOf(4, 5, 6),
    arrayOf(7, 8, 9),
    arrayOf(10, 11, 12)
)

Sample Output 1:

7, 8, 9

Sample Input 2:

val inputArray = arrayOf(
    arrayOf("(¬‿¬)_", "Program"),
    arrayOf("_(^.^)/", "with"),
    arrayOf("(>^_^)>", "Kotlin!")
)

Sample Output 2:

(>^_^)>, Kotlin!
Write a program in Kotlin
fun main() {
var inputArray: Array<Array<String>> = arrayOf()
val n = readLine()!!.toInt()
for (i in 0 until n) {
val strings = readLine()!!.split(' ').toTypedArray()
inputArray += strings
}
// Do not change lines above
// Write your code here

}
___

Create a free account to access the full topic