Quick Sort w/o duplicate values vs. Quick Sort with Dupe values

I thought I had figured this one out- then I forgot I changed the test case to not have dupe values… then it ‘passed’ locally- but not on FCC… sorry for the confusion. Let’s see if I can refactor below to get to work for arrays with dupe values now.

let swap = (arr,a,b) => ([arr[a],arr[b]] = [arr[b],arr[a]]);

let partition = (arr, left, right, pivot) => {
while(left < right){
    while(arr[left] < arr[pivot]){
        left++;
    }
    while(arr[right] > arr[pivot]){
        right--;
    }
if (left < right){
    swap(arr,left,right);
    left++;
    right--;
}
}
return left;
}

let quickSort = (array, left = 0, right = array.length-1) => {
if(left < right){
    let pivot = left;
    let partitionIndex = partition(array,left,right,pivot);
    quickSort(array, left, partitionIndex);
    quickSort(array, partitionIndex+1, right);
}
return array;
}

  // test array:
console.log(quickSort([1, 4, 2, 8, 345, 1123, 431, 32, 5643, 63, 123, 43, 22, 55, 11, 234, 92]));

My best guess:

I think FCC has a timeout function,
that stops the calculation, if your algorithm needs too much time to run.

Meaning: refactor your logic

Your code doesn’t work. Result:

[ 1, 2, 4, 8, 11, 22, 32, 43, 55, 63, 92, 123, 234, 345, 1123, 431, 5643 ]
let partition = (arr, left, right, pivot) => {
while(left <= right){
    while(arr[left] < pivot){
        left++;
    }
    while(arr[right] > pivot){
        right--;
    }
if (left <= right){
    [arr[left],arr[right]] = [arr[right],arr[left]];
    left++;
    right--;
}
}
return left;
}

let quickSort = (array, left = 0, right = array.length-1) => {
if(left == right) return;
    
    let pivot = array[left];
    let partitionIndex = partition(array,left,right,pivot);
    quickSort(array, left, partitionIndex-1);
    quickSort(array, partitionIndex, right);

return array;
}

  // test array:
console.log(quickSort([1, 4, 2, 8, 345, 1123, 431, 32, 5643, 63, 123, 43, 22, 55, 11, 234, 92]));