A music app loops playlists, so two playlists are the same loop if one is the other rotated: it starts at a different song but keeps the same order.
Write isRotation(a, b) that returns true if b can be made by rotating a some number of places (including zero), and false otherwise. Song ids are whole numbers.
Input: a = [1,2,3,4], b = [3,4,1,2] Output: true
Rotating a by 2 gives b.
Input: a = [1,2,3], b = [1,3,2] Output: false
The songs are the same, but the order around the loop is different.
0 <= a.length, b.length <= 10^40 <= a[i], b[i] <= 10^6Run tries your code on the examples. Submit runs every test, including hidden edge cases, and solves the problem when they all pass.
Ctrl + Enter runs, Ctrl + Shift + Enter submits (⌘ on a Mac).
I'm here to help with #83 Same Playlist, Different Start. I give hints, never the solution, so you get to solve it yourself. Ask for a hint, select code to ask about it, or press Ask Tuto why on a failing test.
Your first 3 answers need no account. for free to keep asking.