Interview Question

Quality Assurance Engineer Interview Seattle, WA

Given an array of

integers, how would you move the duplicate integers into a different array? What is the efficiency of your algorithm?
Answer

Interview Answer

1 Answer

2

In Java I'd do this using a hashset and newly created array(of dups). Simply iterate over the array checking first to see if the value already existed in the hashset. If it already exists add to array(of dups) if not add to hashset.

Action on Feb 25, 2012

Add Answers or Comments

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