Example 4 : Quick Sort

TopicDifficultyCompanies
Recursion and Divide & Conquer Approach
HARD
Microsoft
Google
Goldman Sachs

Given an array of integers arr[], write a program to sort the array in ascending order using Quick Sort.

Example 1

Input: arr[] = [5, 2, 3, 1]
Output: [1, 2, 3, 5]
Explanation: Return the sorted array(ascending order)

Example 2

Input: arr[] = [5, 1, 1, 2, 0, 0]
Output: [0, 0, 1, 1, 2, 5]
Explanation: Return the sorted array(ascending order)

Code Editor

Practice and Learn

Best way to learn is through solving real problems. Practice this problem in this code editor.