How to create a method that takes input string and returns the most frequently occurring letter(s) in string?
Prototype of the function: public String Duplicate(String str)
- If there are two or more letters which are most frequently occuring, then return all possibilities in the output.
- The input string should always contain UPPERCCASE characters if any other characters (LOWERCASE) found Return -1.
Input String str = "ABDEFFFGHIJ"
Output The function Duplicate() returns "F"
Input String str= "HIJKLLLMMNOPQQR"
Output The function Duplicate() returns "LMNQ"