Difficulty Level: Easy

Submissions: 6428 Accuracy:


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

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


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.


1 2 2 1 2 0 2 2

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 **

Author: Jaspreet Singh

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

Compilation/Execution Result:

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