Tutorials  Articles  Notifications  Login  Signup


RK

Rajan Kumar

Founder at HackersFriend Updated Aug. 17, 2019, 1:50 a.m. ⋅ 1015 views

Find maximum occurring character in a string


Problem

You are given an string S, Your task is to find out the character whose occurance is most. If there are more than 1 character which have same occurance, then print the one that comes alphabetically first. 

Example

Input

HackersFriend

Output

e

Here in this example, we can see there are two characters which are occuring 2 times, e and r. But e comes first alphabetically, so we print e as our output.

 

Solution

We will use Hashing to solve this problem efficiently.



HackerFriend Logo

Join the community of 1 Lakh+ Developers

Create a free account and get access to tutorials, jobs, hackathons, developer events and neatly written articles.


Create a free account