Implement a method that returns the longest word in a collection via an iterator. If the collection is empty, return ' '.
For loop and iterables
Very long word
Report a typo
Sample Input 1:
cat kotlin programming pythonSample Output 1:
programmingWrite a program in Kotlin
fun findLongestByIterator(strIterator: Iterator<String>): String {
// write your code here
}
fun main() {
val words: List<String> = readLine()!!.split("\\s+".toRegex())
println(findLongestByIterator(words.iterator()))
}
___
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.