Trains the technique from
LeetCode 796Rotate StringThis is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.
Same function shape, different story and different numbers.
A baggage carousel is a closed loop of slots, each stencilled with one lowercase letter. A scanner sits at one point of the loop and reads the letters clockwise from wherever the loop currently rests, producing the string belt.
Nudging the carousel forward by one slot moves the letter that was under the scanner to the far end of the reading and shifts everything else one place earlier. So a nudge turns "cargo" into "argoc".
Return true when some number of nudges, possibly zero, makes the scanner's reading equal target, and false otherwise.
Example 1
Two nudges send l and o to the back of the reading, which lands exactly on the target.
Example 2
The target uses the same five letters, but swapping the last two is not something nudging the loop can do.
Example 3
Nudging never removes a slot, so a shorter target can never be reached.
The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.
def can_align_carousel(belt: str, target: str) -> bool:public boolean canAlignCarousel(String belt, String target)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.