Write a function reverseSentence that takes a sentence as a string and returns a new string with the words in reverse order. The function should use StringBuilder, or even better, buildString, for efficient string manipulation.
StringBuilder
Sentence reversal
Report a typo
Sample Input 1:
Hello world! Kotlin is awesomeSample Output 1:
awesome is Kotlin world! HelloWrite a program in Kotlin
fun reverseSentence(sentence: String): String {
val words = sentence.split(" ")
// Write you code here
}
___
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.