This would just be a comment but it doesn't all fit...
- In compare, you could simply
return a-binstead of doing 2 compares.In compare, you could simplyreturn a-binstead of doing 2 compares. - The print can be done with one pass over the array (O(N)) instead of O(N^2):
...
int i = 0;
int value;
while (i < count) {
value = arr[i];
i++;
while (i < count && value == arr[i]) {
i++;
}
cout << value;
}