Deleting duplicates in an array
807591Apr 15 2008 — edited Apr 16 2008Hey everyone,
I have a quick question - I've been working on a program which creates a random letter array, and then sorts it, and then deletes the duplicates, while moving the rest of the letters to the left to fill the empty space in the array. I think I've got the deleteRepeats part down, but I've been struggling while working on the delete method itself. If anyone could help out I would greatly appreciate it!
(deleteRepeats method)
public static void deleteRepeats(int [] a, int size) {
int temp = a[0];
for (int i = 1; i < size; i++) {
if (temp == a[1]) {
size = delete(a,size);
}
else {
temp = a;
}
}
} // end of deleteRepeats