Microsoft

  www.microsoft.com
Work in HR? Unlock Free Profile

Microsoft Program Manager Internship Interview Question

I interviewed in Mountain View, CA and was asked:
"Here is a string with duplicate characters in java. Remove the duplicate characters. Return value is a string"
Tags: technical, java
Add Tags [?]
Answer

Part of a Program Manager Internship Interview Review - one of 3,411 Microsoft Interview Reviews

Answers & Comments

1
of 1
vote

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

To comment on this question, Sign In with Facebook or Sign Up

Tags are like keywords that help categorize interview questions that have something in common.