I am doing the 30 Days of Code in Kotlin on Hackerrank and I am stuck at Day 7.
How do you read multiple integers on a single line?
How is it added to an array and displayed in reverse?
I have solved it in Java but lack the syntax needed in Kotlin
Input:
4
1 4 3 2
My Code:
fun main(args: Array<String>) { val n = readLine()!!.toInt() var arr = Array(n) for(i in 0 until n) { arr[i] = readLine()!!.toInt() //Not Working? nor does readLine()!!.split(' ').toInt() } for(item in arr.size - 1 downTo 0) { print("${item} ") } }