So here\'s the code I\'ve got so far...
import java.util.Scanner;
class count{
public static void main(String args[]){
Scanner s=new Scanner(Syst
Tips: When you are building the HashMap, at the same time, you can store the maximum value and corresponding character. Still O(n) but the code would be cleaner.
Collections
. Simple and easy.HashMap <Character,Integer>
.String
you have read. For each character in the string, check if it is available in the map (as key). If yes, increment the count, else add the character to the map as key and set the count to 0.