Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static char findRepeating(String s){
- HashMap<Character, Integer> charCount= new HashMap<>();
- int count=0;
- for (int i=0; i<s.length(); i++){
- if (charCount.containsKey(s.charAt(i))){
- count=charCount.get(s.charAt(i));
- charCount.put(s.charAt(i), ++count);
- }
- else{
- charCount.put(s.charAt(i), 1);
- }
- }
- for (Character ch:charCount.keySet()){
- if (charCount.get(ch)==0){
- return ch;
- }
- }
- return '\0';
- }
Advertisement
Add Comment
Please, Sign In to add comment