65. Implement Merge Sort
MediumSorting
Sort nums ascending without using the built-in sort. Merge sort is the suggested approach.
Example 1
Input: nums = [5, 2, 3, 1] Output: [1, 2, 3, 5]
Constraints
1 ≤ nums.length ≤ 5 × 10⁴
MediumSorting
Sort nums ascending without using the built-in sort. Merge sort is the suggested approach.
Input: nums = [5, 2, 3, 1] Output: [1, 2, 3, 5]
1 ≤ nums.length ≤ 5 × 10⁴Tab indents · Ctrl/⌘ + Enter runs · Esc then Tab leaves the editor
Run checks these cases; the expected output comes from the reference solution. Submit judges all 4 hidden and sample tests.
Code runs only in your browser in an isolated sandbox. Progress and submissions are saved on this device.