Netflix: Count pairs of numbers that are rotations of each other
Problem. Given an array of integers, count how many pairs are cyclic rotations of one another, meaning one number's digits can be rotated to produce the other.
Example. 546, 654 and 465 all belong to the same rotation group, so every pair among them counts.
Constraints. The array can hold around 100,000 numbers, which rules out comparing every pair directly.
What mattered. The candidate highlighted that the key step is noticing that rotations of a number form one equivalence class. Once each number is mapped to a single representative of its class, you only need to count how many numbers share each representative.
Context. This sat in the online assessment next to a simple file system simulation with go-to-bucket and create-file commands. The later phone rounds were deliberately vague: removing duplicate shows across home page rows (with follow-ups on millions of shows and shared state across services), a longest subarray without repeats, and counting pairs of show names with no letters in common, where a bitmask optimization was discussed.
Comments 0
No comments yet. Ask the author something, or add what happened in your own round.