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.
- 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
- Select Least Resource TasksOA Β· Seen Jun 2026
- Product Category Group SizesPHONE SCREEN Β· Seen May 2026
- Count Connected ComponentsPHONE SCREEN Β· Seen May 2026
public int findMaximumMaximaCount(String categories) {
// write your code here
}