Quicksort
A sorting algorithm that works by selecting a pivot element and then partitioning the other elements into two lists, depending on if it is greater or less than the pivot. It has the optimal best and average time complexity but can degrade to O(n^2) in the worst case.
Pros |
Cons |
Quicker than merge and heap sorts on average |
Worst case is O(n^2) |
In-place algorithm |
Not stable in most implementations |
LeetCode Problems
Given an array of intervals where intervals[i] = [starti, endi], merge all overlapping intervals, and return an array of the non-overlapping intervals that cover all the intervals in the input.