Back to problems

Prefix Frequency Partition

Algorithm · Amazon · Medium

You are given a string s that consists solely of uppercase English letters 'A' through 'Z'. A positive integer len qualifies as valid when all of the following conditions are met: Some prefix of s has length exactly len. The whole string s can be broken into one or more non-overlapping chunks, each of length len. The character counts of every chunk match the character counts of the prefix s[0..len - 1] exactly. Chunks are allowed to differ as strings; the only requirement is…

Checking your access…