Cycle Shift

Asked at ZipRecruiter · Coding Questions · Difficulty: Medium

A cyclic shift takes some digits from the end of a number and places them at the beginning, while the other digits move forward in order (you may shift none, some, or all digits). Two numbers `a[i]` and `a[j]` are a "cyclic pair" if they have the **same number of digits** and one can become the other by a cyclic shift. Count all pairs `(i, j)` with `0 <= i < j < a.length` that are cyclic pairs.

Loading the problem…