Prefix Maximum Equal-Frequency Block Count

Asked at Amazon · Coding Questions · Difficulty: Medium · Last asked Jan 31, 2026

Given a string `s` of uppercase letters, for each prefix `s[0..i]` compute the maximum integer `k` such that the prefix can be split into `k` contiguous equal-length blocks (so `k` divides the prefix length) where every block has the same 26-letter frequency vector. Output the maximum `k` for each prefix.

Loading the problem…