Basic example
Input
arr = [3,1,4,1,5,9,2,6]
Output
[1, 1, 2, 3, 4, 5, 6, 9]
After merge sort, the list is sorted ascending.
Full lesson preview
Write a merge sort that sorts a list of integers in ascending order using divide and conquer.
Problem statement
Task
Examples
Input
arr = [3,1,4,1,5,9,2,6]
Output
[1, 1, 2, 3, 4, 5, 6, 9]
After merge sort, the list is sorted ascending.
Input format
Output format
Constraints
Samples
Input
arr = [5,2,3,1]
Output
[1, 2, 3, 5]
Sorted ascending order returned.