Company: amazon_3march
Difficulty: medium
A logistics team at a shipping company is making sure every package is routed to the right sorting line. Each package carries a label that is a single uppercase English letter, and the full sequence of labels is given as the string packages , where the i th character is the label of the i th package. To streamline sorting, the team wants to examine every prefix of packages (from length 1 up to n ) and work out the greatest number of equal-sized parts each prefix can be split into, subject to: Each part must have the same frequency of every character as every other part in that division Given a string packages , calculate for each prefix t (from length 1 to n ), the maximum number of equal parts into which the prefix can be divided, such that each part has the same number of occurrences of each character. Example Given, packages = "ABAB". In the given example t represents prefix string and length represents the length of the prefix string. Prefix string length Explanation Maximum number