My Solution keeps giving me this error condition.
quickSort
should not use the built-in .sort()
method
I read another post suggesting that I should remove all comments, but is seems the recursive call of quickSort is the issue.
I am wondering if this test was broken my mistake, As all the other tests are passing.
Your code so far
function quickSort(array) {
// Only change code below this line
let start = arguments[1] || 0
let end = arguments[2] || array.length - 1
if (end <= start) return array
let pivot = array[end]
let i = start - 1
for(let j = start; j <= end - 1; j++) {
if(array[j] < pivot) {
i++
let temp = array[i]
array[i] = array[j]
array[j] = temp
}
}
i++
let temp = array[i]
array[i] = array[end]
array[end] = temp
pivot = i
array = quickSort(array, start, pivot - 1)
array = quickSort(array, pivot + 1, end)
return array
// Only change code above this line
}
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36
Challenge: Algorithms - Implement Quick Sort
Link to the challenge: