Write a function to reverse words in a given string.
MediumProblem Statement
Write a function to reverse words in a given string.
Sample Input
A string: "Hello World"
Sample Output
Reversed string: "World Hello"
Limits
Time: 2s · Memory: 256 MB
Code Editor
00:00
fun isPrime(num: Int): Boolean {
// Add your code here to check if a number is prime
}
fun sumOfPrimes(limit: Int): Int {
// Add your code here to calculate the sum of primes
}
fun main() {
val limit = 10
println("The sum of prime numbers below $limit is: ${sumOfPrimes(limit)}")
}
Input
A string: "Hello World"
Expected Output
Reversed string: "World Hello"