Find Maximum Maxima Count π
Learn this problemProblem statement
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.
Function
findMaximumMaximaCount(categories: String) β int
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! ΰΌΒ·Λ
Examples
Example 1
categories = "bccaaacb"return = 6
Example 2
categories = "zzzz"return = 4Example 3
categories = "adbcbcbcc"return = 6Constraints
- The length(categories) <= 10^5
- The string categories consists of lowercase English characters only.
More Amazon problems
- Drone Delivery RouteOA Β· Seen Aug 2026
- Package Dependency OrderPHONE SCREEN Β· ONSITE INTERVIEW Β· Seen Aug 2026
- Unfulfilled Customers by Inventory PriorityOA Β· Seen Aug 2026
- Calculate Beauty ValuesOA Β· Seen Aug 2026
- Maximize Distance to the Closest Occupied SeatONSITE INTERVIEW Β· Seen Aug 2026
- Package Delivery SystemOA Β· Seen Aug 2026
- Select Least Resource TasksOA Β· Seen Aug 2026
- Maximum Length-K Window Sum over Sparse SegmentsOA Β· Seen Aug 2026