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
Tags:
technical, java
Answer

Interview Answer

1 Answer

1

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 Question, Sign In with Facebook or Sign Up