← Questions

Count pairs of numbers that are digit rotations of each other

0
DatabricksCodingLast asked Aug 2024

Two numbers form a pair when they have the same number of digits and one becomes the other by moving some leading digits to the end (a rotation; no rotation counts too). Given an array, count the index pairs i < j that form a pair. Map each number to a canonical form, such as its smallest rotation, and count equal forms.

Write and test your solution herePython in your browser, the question's tests level by level, every submission kept for you.Sign in to start coding