See full Google Engineering Staff Interview or all Google Interviews
Interview Question for Engineering Staff at Google: |
Oct 23, 2009 |
Helpful Question?
Yes |
No
Answers & Comments (2)
Helpful Answer?
Yes |
No
Inappropriate?
0 of 0 people found this helpful
by ellemeno:
removeDupes(int[] a){
int uniqueCount = 0;
for (int i = 0; i < n; i++){
if (a[i] not in hash table) {
add a[i] to hash table with value uniqueCount;
uniqueCount++;
}
}
set = get key-value pairs from hash table;
for (each element e in set) {
a[e.value] = e;
}
for (int i = uniqueCount; i < n; i++){
a[i] = null;
}
}