BETA

Difficulty Level: Easy

Submissions: 5695 Accuracy:

42.42%

Given a linked list of 0s, 1s and 2s, sort it. (Function Problem)
     

Given a linked list of 0s, 1s and 2s, sort it.

Input:

Complete the method which takes one argument: the head of the linked list. The program should not read any input from stdin/console.
The struct Node has a data part which stores the data and a next pointer which points to the next element of the linked list. 
There are multiple test cases. For each test case, this method will be called individually.

Output: The function should not print any output to stdin/console.
 

Example:

Input:
1 2 2 1 2 0 2 2

Output:
0 1 1 2 2 2 2 2 

For Testing(format):

1(Test cases)
8(Number of elements in Link List)
1 2 2 1 2 0 2 2 

 

 

** For More Input/Output Examples Use 'Expected Output' option **


					   
It is recommended to 'Compile & Test' your code before clicking 'Submit'!

Compilation/Execution Result:

Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.