Question bank › Hashing
Dsa Hashing Medium

The Caesar Cipher Clusters

You are analyzing encrypted messages. Two strings are considered 'shift-equivalent' if one can be transformed into the other by shifting every character by the same constant K (wrapping around the alphabet). For example, 'abc' and 'bcd' are equivalent (shift of 1), and 'xyz' and 'zab' are equivalent (shift of 2). Given a list of N lowercase strings, find the size of the largest group where every string in the group is shift-equivalent to every other string. Input Format: The first line contains an integer N. The next N lines each contain a single string of lowercase English letters. Output Format: Print a single integer representing the size of the largest shift-equivalent group. Example: Input: 5 abc bcd ace bdf xyz Output: 3 (Note: 'abc', 'bcd', and 'xyz' are in one group; 'ace' and 'bdf' are in another.)

Key concepts

hashingstring-normalizationfrequency-maps

Practise this out loud — free

Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.

🎙 Practise this question now
Part of Praxari's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.