Check if String is a Rotation

Hashing, Sorting, and Parsing DSA practice problem on Onlearn.

Difficulty: medium.

Topics: How can you check whether one string is a rotation of another?, Strings, String Manipulation, Time Complexity, Space Complexity, Big O Notation, string matching, string searching, brute force, string operations, String Comparison, Substring Search, String Manipulation.

Problem: String Rotation Check Given two strings, s1 and s2, determine if s2 is a rotation of s1. A string s2 is considered a rotation of s1 if s1 can be transformed into s2 by moving some characters from the beginning of s1 to its end, in a circular fashion. Input The first line contains a string s1. The second line contains a string s2. Both strings will consist of lowercase English letters. Output Print true if s2 is a rotation of s1, otherwise print false. Constraints 1 <= length(s1), length(s2) <= 10^5 Examples Example 1: Input: Output: Explanation: If "abcde" is rotated by 2 positions to the right, it becomes "cdeab". Example 2: Input: Output: Explanation: "acb" cannot be obtained by rotating "abc".