An image carousel keeps its slides in slides. Pressing "next" k times moves every slide k places to the right, and slides that pass the end come back at the start.
Write rotateCarousel(slides, k) that rotates slides in place, using O(1) extra memory. The array itself is checked after the call.
Input: slides = [1,2,3,4,5], k = 2 Output: [4,5,1,2,3]
The last two slides wrap around to the front.
Input: slides = ["a","b","c"], k = 4 Output: ["c","a","b"]
Rotating 3 slides by 4 is the same as rotating by 1.
0 <= slides.length <= 10^50 <= k <= 10^9Run 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 #82 Rotate the Carousel Right. 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.