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

Programming Exercises

Implement a program to check if two strings are rotations of each other.

Medium

Problem Statement

Implement a program to check if two strings are rotations of each other.

Sample Input

std::string str1 = "abcd", str2 = "cdab";

Sample Output

Strings are rotations of each other.

Limits

Time: 2s · Memory: 256 MB

Code Editor
00:00
#include <iostream> #include <string> int main() { std::string str1 = "abcd", str2 = "cdab"; // Logic to check for rotations return 0; }
Log in or sign up to run or submit your code.Log inSign up
Input
std::string str1 = "abcd", str2 = "cdab";
Expected Output
Strings are rotations of each other.