Write a function checkElements(), which checks if a list of names contains a certain name and returns true when the element is present in list.
Collections as interface
Is it true?
Report a typo
Sample Input 1:
Gabrielle John Mary Brianna Jordan James Caroline Elizabeth Gilbert Morgan
BelindaSample Output 1:
false
falseWrite a program in Kotlin
fun main() {
val nameList = readln().split(" ").toMutableList()
val nameSet = nameList.toMutableSet()
val name = readln()
println(checkElements(nameList, name))
println(checkElements(nameSet, name))
}
// Write here function checkElements()
___
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.