Question: import java.util. * ; class MostFrequentDSA { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System
import java.util.;
class MostFrequentDSA
public static void mainString args
Scanner sc new ScannerSystemin;
String s scnextLine;
Object ans mostFrequentDSAs;
System.out.printlnans ans;
static Object mostFrequentDSAString s
Problem Description
You are given a string which comprises lower case alphabets az upper case alphabets AZ numbers, 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 because A has lower ASCII value than a
Input format
Input will contain line containing a string S
Output format
You've to output two things which will be separated by a space: a The character which occurs the maximum number of times. b The number of its occurrence.
Sample Input
Statements are unique.
Sample Output
e
Explanation
e occurs times.
Constraints
S
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
