Open
Description
Maybe the array in the test is a descending array,so the partition function should following like this:
function partition(arr, start, end) {
let i = start;
let pivot = arr[end];
for (let j = start; j < end; j++) {
if (arr[j] > pivot) {
swap(arr, i, j);
i += 1;
}
}
swap(arr, i, end);
return i;
}
Metadata
Metadata
Assignees
Labels
No labels