Morgan Stanley Interview Question

Onsite#6 Return all characters from a string which appeared more than once

Interview Answer

Anonymous

Nov 12, 2018

Maintain a HashSet while iterating over a character array, if hashset already has character then add it into resulting ArrayList. An alternate approach is to maintain a counter for each character in a hashmap and then iterate over hashmap and return all elements appears more than x # of times.