Rotation of Each Other
Is B a rotation of A (obtainable by moving a prefix of A to its end)?
Input: two lines: string A, then string B.
Output: YES or NO.
Constraints:
- 1 ≤ |A|, |B| ≤ 104
- lowercase letters
Sample Tests
Input 1
abcde cdeab
Output 1
YES
Input 2
abc acb
Output 2
NO
Discussion (opens after you solve — no spoilers before)
No comments yet.