[Amazon] sde intern oa

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 CategoryMaxCount of a category. It is the number of indices where the frequency of some category is maximum among all categories present in the prefix of i.

More elaborately, CategoryMaxCount of character, char, representing a category is defined as the number of indices i such that the frequency of char is maximum in the prefix of the string up to the index i.

Given the string categories, find the maximum CategoryMaxCount among all the categories.

Example

Given categories = "bccaaacb", there are three categories [a, b, c].

Index ->
Character
1
b
2
c
3
c
4
a
5
a
6
a
7
c
8
b
a00012333
b11111112
c01222233

From the above table (assuming 1-based indexing):

  • CategoryMaxCount of a = 4 at indices 5, 6, 7, 8
  • CategoryMaxCount of b = 2 at indices 1, 2
  • CategoryMaxCount of c = 6 at indices 2, 3, 4, 5, 7, 8

Thus the maximum CategoryMaxCount is 6 for the character c.


我们长期稳定承接各大科技公司如TikTok、Google、Amazon等的OA笔试代写服务,确保满分通过。如有需求,请随时联系我们。

We consistently provide professional online assessment services for major tech companies like TikTok, Google, and Amazon, guaranteeing perfect scores. Feel free to contact us if you're interested.

Leave a Reply

Your email address will not be published. Required fields are marked *