You have a mutable list of integers numbers. Add the sum of all list elements to the beginning of the list. Then delete the second-to-last item in the list. The system guarantees that the length of the array is greater than 2.
Work with MutableLists
Playing with numbers
Report a typo
Sample Input 1:
8 11 1 2 3Sample Output 1:
25 8 11 1 3Write a program in Kotlin
fun main() {
val numbers = readLine()!!.split(' ').map { it.toInt() }.toMutableList()
// do not touch the lines above
// write your code here
// do not touch the lines below
println(numbers.joinToString(" "))
}
Create a free account to access the full topic
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.