← 返回 microsoft 的题目列表Max Frequency Character in Stream with getNext and getMax APIs
类型:online_judge
microsoft
You have a stream of characters like "aaabbbvvvvcccccccccccc..." from which you can continuously get the next character using the getNext() API. Provide another API getMax() which returns the character with the highest current occurrence.
Input
getNext(): Returns the next character from the stream
getMax(): Returns the character with the highest occurrence
Output
The character returned by getMax.
Example
Stream: Calling getNext() sequentially yields characters 'a', 'a', 'a', 'b', 'b', 'b', 'v', 'v', 'v', 'v'...
Calling getMax(): returns 'v'
Constraints
The length of the stream does not exceed 100,000.
Example
Input
aaabbbvvvvcccccccccccc