Practice Real Company Assessment Patterns • Latest 2025–2026 Mock Tests

Programming Exercises

Write a function to reverse words in a given string.

Medium

Problem 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)}") }
Log in or sign up to run or submit your code.Log inSign up
Input
A string: "Hello World"
Expected Output
Reversed string: "World Hello"