Yahoo Interview Question Software Engineer / Developers
0of 0 votesAn array of size k contains integers between 1 and n. You are given an additional scratch array of size n.
Compress the original array by removing duplicates in it. What if k << n?

the case where K is comparable to n can be solved using counting sort and hence omittin the duplicate counts.the case where k<<n degrades the performance of the counting algo.in that case we can use hash table to map the numbers using an appropriate hash function.do not map the elements in table if they have been already mapped before.
- saumils1987 on September 13, 2010 Edit | Flag Reply