You have a mutable list of integers numbers. Add the sum of all list elements to the beginning of the list. Then delete the penultimate item in the list. It is guaranteed 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(" "))
}
___
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.
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.