educative.io

Quicksort solution produces duplicates

The example code for quicksort at https://www.educative.io/module/lesson/data-structures-in-javascript/x1xMpgK05g9
produces duplicates in output:

Before Sorting
[ 55, 23, 26, 2, 18, 78, 23, 8, 2, 3 ]
After Sorting
[ 2, 2, 3, 8, 18, 23, 23, 26, 55, 78 ]

sort-an-array-using-quicksort-algorithm__arrays__coderust-hacking-the-coding-interview

Hey @mp0wr

Quicksort algorithm generally doesn’t remove duplicates, so we didn’t handle that case. We will update the lesson with duplicate removal case too.

Happy learning,