Given a linked list of 0s, 1s and 2s, sort it.
Submissions: 11310   Accuracy:


  Difficulty: Easy   Marks: 2

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

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

to report an issue on this page.