Problem title
Difficulty
Avg time to solve

Number of balanced binary trees
Easy
10 mins
Count Palindromic Subsequences
Hard
15 mins
Search a 2D Matrix II
Easy
15 mins
Goku and Dragon Balls
Moderate
35 mins
Single Number II
Easy
15 mins
Remove Duplicates from Sorted Array
Easy
15 mins
Hard
10 mins
Sub Matrices With Sum Zero
Moderate
15 mins
Combination Sum II
Moderate
30 mins
Minimum Swaps
Moderate
10 mins
11

Difficulty: MEDIUM
Contributed By
Avg. time to solve
30 min
Success Rate
60%

Problem Statement

#### For a given Singly Linked List of integers, sort the list using the 'Merge Sort' algorithm.

##### Input format :
``````The first and the only line of input contains the elements of the linked list separated by a single space.
``````
##### Remember/Consider :
``````While specifying the list elements for input, -1 indicates the end of the singly linked list and hence, would never be a list element
``````
##### Output format :
``````The only line of output contains the sorted elements of the Singly Linked List in a row, separated by a single space.
``````
##### Note:
``````You are not required to print the elements, just sort the elements and return the head to the updated Singly Linked List.
``````
##### Constraints :
``````1 <= N <= 10^5
1 <= DATA <= 10^9

Where 'DATA' denotes the value of node of Linked List.

Time Limit: 1sec
``````
##### Sample Input 1 :
``````1 4 5 2 -1
``````
##### Sample Output 1 :
``````1 2 4 5
``````
##### Sample Input 2 :
``````10 9 8 7 6 5 4 -1
``````
##### Sample Output 2 :
``````4 5 6 7 8 9 10
``````
Console