Quick Sort
Implement quickSort
Given an array of integers, sort it in non-decreasing order using **Quick Sort** — pick a pivot, partition the array around it so every smaller value ends up on its left and every larger value on its right, then recursively sort each side.
Unlike merge sort, quicksort does its work while partitioning rather than while merging, and it never needs to allocate a second array to combine results — everything happens in place. The catch is that its performance depends entirely on how well the chosen pivot splits the range each time, which is exactly what separates a naive implementation from a solid one.
Example 1:
Input: arr = [7,2,9,4,2,8]
Output: [2,2,4,7,8,9]
Example 2:
Input: arr = []
Output: []
Example 3:
Input: arr = [5]
Output: [5]
+ 5 hidden test cases run on Submit.
Constraints:
- ●
0 ≤ arr.length ≤ 200 - ●
-1000 ≤ arr[i] ≤ 1000 - ●
Sort in non-decreasing order
arr =
[7, 2, 9, 4, 2, 8]