Microsoft Interview Question: Here is a string with duplica... | Glassdoor

Interview Question

Program Manager Internship Interview Mountain View, CA

Here is a string with duplicate characters in java. Remove

  the duplicate characters. Return value is a string
technical, java

Interview Answer

1 Answer


You can use a hashtable for this -- if you find any collisions, (i.e., if hashtable.contains(character at position i in a for loop), then don't add that character to your new string. There are plenty of less-efficient ways to do this, but the hashtable answer is what I used for making it more efficient.

Interview Candidate on Mar 10, 2011

Add Answers or Comments

To comment on this, Sign In or Sign Up.