A team at Amazon is working to ensure all packages are correctly sorted for delivery. Each package has a label represented by an uppercase English letter. The full list of labels is given as the string packages, where the ith character is the label of the ith package.
To optimize the sorting process, the team wants to analyze each prefix of the string packages (from length 1 to n) and determine the maximum number of equal parts it can be divided into. Each part must satisfy the following conditions:
- 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.
packages = "ABAB" return = [1, 1, 1, 2]

Given, packages = "ABAB".
In the given example t represents prefix string and length represents the length of the prefix string.
Return [1, 1, 1, 2] as the answer.
- Sort Bug Report FrequenciesOA · Seen Jun 2026
- Count Promotional PeriodsOA · Seen Jun 2026
- Find Maximum Total Amount (SDE I, Fungible :)Seen Jun 2026
- Get Minimum AmountOA · Seen Jun 2026
- Find Minimum CostOA · Seen Jun 2026
- Get Smallest Base SegmentOA · Seen Jun 2026
- Maximum Non-Adjacent House ValueONSITE INTERVIEW · Seen Jun 2026
- Running Delivery Time MediansONSITE INTERVIEW · Seen Jun 2026
public int[] maximumEqualParts(String packages) {
// write your code here
}