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

Programming Exercises

Write a function to check if a string is a rotation of another string.

Medium

Problem Statement

Write a function to check if a string is a rotation of another string.

Sample Input

Two strings: str1 = "abcd", str2 = "cdab"

Sample Output

"cdab is a rotation of abcd"

Limits

Time: 2s · Memory: 256 MB

Code Editor
00:00
fun main() { val sentence = "Kotlin programming is fun" // Add your code here to find the longest word }
Log in or sign up to run or submit your code.Log inSign up
Input
Two strings: str1 = "abcd", str2 = "cdab"
Expected Output
"cdab is a rotation of abcd"