Finding first non repeated character in the String using Hash map

You are given a String and a hashmap. You need to use the Hashmap to find the first non repeated character in the String. Input : aaabbcd Result: c Input : null Result: ' ' Input: HelloKHello Result: K You MUST use the hashmap passed as an argument in your solution. Otherwise, your test cases won't succeed. Your Answer.java must implement the following interface. import java.util.Map; public interface FirstNonRptedCharInterface { public char FindFirstNonRepeatedCharacter(String inputString, Map<Character, Integer> inputMap); }

Answer

No comments:

Post a Comment