United Kingdom of two collections

Report a typo

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.

Sample Input 1:

8 12 25 56 192 32 76 21
12 67986 12 889 9898 12 3232

Sample 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 3232
Write 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()
___

Create a free account to access the full topic