Write a function addListToCollection(), which takes two collections of different strings as parameters and adds the elements from the second collection to the first one.
Collections as interface
United Kingdom of two collections
Report a typo
Sample Input 1:
8 12 25 56 192 32 76 21
12 67986 12 889 9898 12 3232Sample Output 1:
8 12 25 56 192 32 76 21 12 67986 12 889 9898 12 3232
8 12 25 56 192 32 76 21 67986 889 9898 3232Write a program in Kotlin
fun main() {
val oldList = readln().split(" ").toMutableList()
val oldSet = oldList.toMutableSet()
val addedList = readln().split(" ").toList()
addListToCollection(oldList, addedList)
addListToCollection(oldSet, addedList)
println(oldList.joinToString(" "))
println(oldSet.joinToString(" "))
}
// Write here function addListToCollection()
___
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.