Microsoft Interview Question

find duplicates in an array with space efficiency

Interview Answers

Anonymous

Oct 28, 2016

Assuming that for every array element we have: 1. a .equals() type of method/function (for checking duplicates) 2. a .compare() type of method/function (for sorting) Since you are striving for space efficiency and not speed, maybe what you could do is sort the array using a good sorting technique (that does not cost too much space to perform) and then run through array checking for adjacent duplicates (as sorting will put duplicates next to one another)..

1

Anonymous

Nov 18, 2016

When did they reply after the interview?