```
function swap(arr, i, j) {
var temp = arr[i];
arr[i] = arr[j];
arr[j] = temp;
}
function partition(arr, pivot, left, right) {
var pivotValue = arr[pivot],
partitionIndex = left;
for (var i = left; i < right; i++) {
if (arr[i] == pivotValue) {
return -1;
}
if (arr[i] < pivotValue) {
swap(arr, i, partitionIndex);
partitionIndex++;
}
}
swap(arr, right, partitionIndex);
return partitionIndex;
}
function quickSort(arr, left, right, found) {
var len = arr.length,
pivot,
partitionIndex;
if (left < right) {
pivot = right;
partitionIndex = partition(arr, pivot, left, right);
if (partitionIndex == -1) {
found += 1;
} else {
found += quickSort(arr, left, partitionIndex - 1, found);
found += quickSort(arr, partitionIndex + 1, right, found);
}
}
return found
}
function check(str) {
if (quickSort(str.split(''), 0, str.length, 0) > 0) {
return 'duplicates found';
} else {
return 'all unique';
}
}
```

This implementation use the quick sort algorithm. The magic happens in the partition function.

Each time the letter at the pivot position is the same as the one at the position i, then we return -1.

In the quicksort function, if the returned pivot has a value of -1, then we increment the value > found.

at the end. we check if the value found is greater than 0. If it is the case, than it means that we have a duplicate.