Practice Sort an Array
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Medium#912
LeetCode ProblemSort an Array
Problem Statement
Given an array of integers nums, sort the array in ascending order and return it. You must solve the problem without using any built-in functions in O(nlog(n)) time complexity and with the smallest space complexity possible.
Source: Sort an Array on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
Input
nums = [5,2,3,1]
Output
[1,2,3,5]
# Example 2
Input
nums = [5,1,1,2,0,0]
Output
[0,0,1,1,2,5]
Constraints
1 <= nums.length <= 5 * 10^4
-5 * 10^4 <= nums[i] <= 5 * 10^4
Related LeetCode Problems
Practice more problems similar to Sort an Array.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.