Start learning free

LESSON 282 OF 410 · DIVIDE AND CONQUER

Quick Sort in JavaScript - O(n log n) Time Complexity

Practice O(n log n)

In this video lesson we will study how the Quick Sort algorithm works, we will analyze its time and space complexities and then we will implement it:


Problem - Quick Sort:

Given an array of integers nums, sort it in ascending order using Quick Sort

Example 1:

Input: nums = [3, 1, 3, 2, 5, 4]
Output: [1, 2, 3, 3, 4, 5]

Note:

Your algorithm should run in O(n log n) time on average and use O(log n) extra space on average (for the recursion).


STEP 1 OF 16
    Ctrl + Enter to check

    Quick Sort in JavaScript

    Keep going with JavaScriptAbout 340 step-by-step lessons, from your first line of code to coding interviews. Free to start.
    Start learning free