Maximum occurrence
Practice
3.5 (685 votes)
Ad Hoc
Approved
Basic programming
Easy
Hash maps
Hiring
Open
Problem
90% Success 19766 Attempts 20 Points 1s Time Limit 256MB Memory 1024 KB Max Code

You are given a string which comprises of lower case alphabets (a-z), upper case alphabets (A-Z), numbers, (0-9) and special characters like !,-.; etc.

You are supposed to find out which character occurs the maximum number of times and the number of its occurrence, in the given string. If two characters occur equal number of times, you have to output the character with the lower ASCII value.

For example, if your string was: aaaaAAAA, your output would be: A 4, because A has lower ASCII value than a.

Input format:
The input will contain a string.

Output format:
You've to output two things which will be separated by a space:
i) The character which occurs the maximum number of times.
ii) The number of its occurrence.

Constraints:
The maximum length of the string can be 1000.

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:20
16 votes
Tags:
Data StructuresEasyHash MapsHash Tables
Points:20
28 votes
Tags:
Ad-HocApprovedBasic ProgrammingEasyHash MapsOpen
Points:20
256 votes
Tags:
Ad-HocApprovedBasic ProgrammingEasyOpen