Array Rotation Checker
Medium
array
rotation
string-matching
Problem Description
Given two arrays, determine if one array is a rotation of another. A rotation means elements are shifted circularly.
Input Format
First line contains n (array size). Second line contains first array. Third line contains second array.
Output Format
Print "YES" if second array is rotation of first, "NO" otherwise
Constraints
1 ≤ n ≤ 1000, 1 ≤ array elements ≤ 1000
Sample Input/Output
Input:
5 1 2 3 4 5 3 4 5 1 2
Output:
YES
Explanation
Second array is first array rotated left by 2 positions
Solution Hints
- Read carefully: Understand input/output format and constraints
- Start simple: Think of brute force solution first, then optimize
- Edge cases: Consider empty inputs, single elements, max constraints
- Data structures: Choose arrays, hash maps, sets based on problem needs
- Time complexity: Ensure your solution fits within time limits
- Test examples: Verify logic with provided sample inputs
180
Points
Points
2000ms
Time Limit
Time Limit
256MB
Memory Limit
Memory Limit
Code Editor
Register to Access Code Editor
Create a free account to solve coding problems and track your progress.
Register Now