Segregate Node Of Linkedlist Over Pivot Index

medium
1. Given a singly linklist, Segregate Node of LinkedList over pivot index and return starting node of linkedlist.
2. pivot will be any random index in range of 0 to length Of Linkedlist
3. After segregation pivot Element should have to be present at correct position as in sorted linkedlist.

Input Format

1->5->2->9->5->14->11->1->10->10->1->3->null 11

Output Format

1->2->1->1->3->5->9->5->14->11->10->10->null

Constraints

-10^6 <= size Of LinkedList <= 10^6
0 <= pivot Index <= 10^6

Notice

Try First, Check Solution later

1. You should first read the question and watch the question video.
2. Think of a solution approach, then try and submit the question on editor tab.
3. We strongly advise you to watch the solution video for prescribed approach.

Example

Input
12
1 5 2 9 5 14 11 1 10 10 1 3 
7
Output
1 1 1 5 2 9 5 14 11 10 10 3 
Previous
Segregate Node Of Linkedlist Over Last Index.
Next
Add First In Doubly Linkedlist

Related Questions