Code RoomRotate array match
MediumPrep Room Coding #356

Rotate array match

CodingAlgorithms & data structuresEntry–Mid~14 min

A circular conveyor belt carries labelled totes past a scanner. Two snapshots of the belt were taken at different moments, each listing tote labels in belt order starting from the scanner. Return true if the second snapshot could be the same belt photographed later — that is, if it can be obtained by rotating the first snapshot — and false otherwise. Two empty snapshots match. Example: [1, 2, 3, 4] and [3, 4, 1, 2] match.

Implement
same_belt(first: list[int], second: list[int]) → bool
Examples
in[[1,2,3,4],[3,4,1,2]]outtrue
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 14 min
InputExpectedGot
[[1,2,3,4],[3,4,1,2]]truenot run yetsample