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

Programming Exercises

Write a function to reverse the order of words in a string.

Hard

Problem Statement

Write a function to reverse the order of words in a string.

Sample Input

A hardcoded string, e.g., "Kotlin is awesome"

Sample Output

Reversed words: awesome is Kotlin

Limits

Time: 2s · Memory: 256 MB

Code Editor
00:00
fun reverseWords(input: String): String { // Add your code here to reverse the words } fun main() { val input = "Kotlin is awesome" println("Reversed words: ${reverseWords(input)}") }
Log in or sign up to run or submit your code.Log inSign up
Input
A hardcoded string, e.g., "Kotlin is awesome"
Expected Output
Reversed words: awesome is Kotlin