Carousel rotation
A storefront carousel shows product IDs in order. Every night it advances k positions: the first k products move to the back and everything else slides toward the front. Given the current ID list and a non-negative k (which may be larger than the list length), return the carousel after one night. Example: [1, 2, 3, 4, 5] with k = 2 becomes [3, 4, 5, 1, 2].
Implement
advance_carousel(ids: list[int], k: int) → list[int]Examples
in
[[1,2,3,4,5],2]out[3,4,5,1,2]What a strong answer looks like
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.
0:00 of about 12 min
solution.py
InputExpectedGot
[[1,2,3,4,5],2][3,4,5,1,2]not run yetsample