Cycle Shift
Problem Overview
- Count pairs (i, j) with i < j where two numbers have the same digit length and one can become the other via a cyclic shift of digits.
- Input: array of positive integers; Output: the total number of such cyclic pairs; Constraints: array length 1–100, values 1–10^4.
- Context: evaluates equality under digit rotations by moving ending digits to the front.
- Source: Asked in Ziprecruiter interviews; a classic coding interview interview question problem.
Example
Unlock to view complete problem details
and practice with sample input/output
Was this article helpful?
View Test Cases & Run Code requires membership
Input Variables
Execution Result:
