All Problems
hardFunctions

Merge Sort

Problem Statement
Implement merge sort and sort an array of n integers.

SAMPLE INPUT

6
38 27 43 3 9 82

SAMPLE OUTPUT

3 9 27 38 43 82

CONSTRAINTS

  • 1 <= n <= 10000

Explanation: Divide the array into halves, sort each half, then merge them.

Code Editor
Output
Click "Run" to see output...