Delete comment from: Javarevisited
14) Remove duplicate characters from a string while maintaining order (must use LinkedHashMap.
public static String removeDuplicateChar(String input) {
System.out.println("Removing duplicate characters in String: \"" + input + "\"...");
Map charMap = new LinkedHashMap();
for(int i = 0; i e : charMap.entrySet()) {
if(e.getValue() == 1)
sb.append(e.getKey());
}
System.out.println(sb.toString());
return sb.toString();
}
Aug 29, 2017, 12:07:59 PM
Posted to Top 20 String Algorithm Questions from Coding Interviews