Segregate 012 Node Of Linkedlist By Swapping Data
easy
1. Given a singly linklist, Segregate 012 Node of LinkedList and return pivot node of linkedlist. 2. After segregation zero nodes should come first and then ones node followed by two's nodes. 3. You are only allowed to swap data not swap nodes.
Constraints
-10^6 <= size Of LinkedList <= 10^6
Format
Input
1->0->1->0->0->1->2->1->1->1->2->1->1->null
Output
0->0->0->1->1->1->1->1->1->1->1->2->2->null
Example
Sample Input
17
2 2 0 2 1 0 0 2 2 1 2 1 2 0 1 0 0
Sample Output
0 0 0 0 0 0 1 1 1 1 2 2 2 2 2 2 2