Write a function that returns True if one array is a rotation of another. Example:
[1, 2, 3, 4, 5, 6, 7]
is a rotation of[4, 5, 6, 7, 1, 2, 3]
. NOTE: There are no duplicates in each of these arrays. REMINDER: Use lists instead of arrays in Python for simplicity.
I've written an implementation that determines the solution in O(n)
time complexity, where n
is the number of elements in array 1.
Languages Implemented:
- JavaScript
- Python