BlackFridaySale

Join the waitlist for an extra exclusive deal

Extra savings end in
01Days
00Hrs
28Mins
57Secs
Limited spots only

782. Maximum Occurring Character in a String

Given a string s, return the character that occurs the maximum number of times in the string.

If multiple characters have the same highest frequency, return the lexicographically smallest character among them.

Example 1:

Input: s = "takeuforward"

Output: "a"

Explanation: 'a' and 'r' appear 2 times each, but 'a' < 'r', so return 'a'.

Example 2:

Input: s = "apple"

Output: "p"

Explanation: 'p' occurs 2 times, more than others.

Now Your Turn!

Pick the correct output for the given input

Input: s = "zzxyyy"

Still unsure what the problem is asking ?

Let’s go through a few more examples, step by step, to make it clearer.

Constraints:

  • 1 <= s.length <= 105
  • The string contains only lowercase English letters ('a' to 'z')
0
class Solution {
public:
char maxOccurringChar(const string& s) {
// Your code goes here
}
};
Test Case

Input:

S