Matching animation cycles
A game engine stores each looping animation as a cycle of frame codes, one lowercase letter per frame, written down starting at whichever frame the artist happened to pick first. Two cycles play the same loop when one becomes the other by moving some number of frames from the front to the back, so cab and abc are the same loop while abc and acb are not. Cycles of different lengths are never the same loop, even when one is the other repeated. Given cycles, return a list holding, for each cycle, the index of the earliest cycle in the list that plays the same loop. A cycle that matches nothing earlier reports its own index, so the first entry is always 0. Two empty cycles play the same empty loop.
first_equivalent_cycle(cycles: list[str]) → list[int][["abc","cab","acb"]]out[0,0,2][["ab","ba","ab"]]out[0,0,0][["ab","abab"]]out[0,1]State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.
[["abc","cab","acb"]][0,0,2]not run yetsample[["ab","ba","ab"]][0,0,0]not run yetsample[["ab","abab"]][0,1]not run yetsample