Code Room
CodingMediumcod-g1180
Subject ArraysLevel Entry–Mid~14 minCommon in Algorithms & data structures interviewsIndustries Software development

Question

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.

Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.

Run or narrate your approach, then ask the coach.