Amazon has a string of categories of items purchased by a particular customer, each represented as a lowercase English letter. To analyze customer behavior, we define a metric called the MaximaCount of a category. It is the number of indices where the frequency of some category c is maximum among all categories present in the prefix.
More elaboratively, MaximaCount of character, char, representing a category is defined as the number of indices i, such that the frequency of char is maximal in the prefix of the string up to the index i.
Given the string categories, find the maximum MaximaCount among all the categories.
Complete the function findMaximumMaximaCount in the editor.
findMaximumMaximaCount has the following parameter:
string categories: the given string
Returns
int: the maximum MaximaCount
β«βqβͺ π³π ππΈΛβ¬ οΎ1013rd thank you on the way to spike! ΰΌΒ·Λ
categories = "bccaaacb" return = 6

categories = "zzzz" return = 4
categories = "adbcbcbcc" return = 6
- The length(categories) <= 10^5
- The string categories consists of lowercase English characters only.
- Get the Fewest Moves (~Operations~)~Seen Jun 2026
- Create Array Generator ServiceSeen Jun 2026
- Minimum Merge ConflictsOA Β· Seen Jun 2026
- Get Minimum AmountOA Β· Seen Jun 2026
- Drone Delivery RouteOA Β· Seen Jun 2026
- Minimum Operations to Make Array ValidOA Β· Seen Jun 2026
- Sort Bug Report FrequenciesOA Β· Seen Jun 2026
- Maximum Equal Parts for PrefixesOA Β· Seen Jun 2026
public int findMaximumMaximaCount(String categories) {
// write your code here
}