Given head of a singly linked list, every node have int data Node next (next pointer) Node higher (null) Node smaller (null) You need to update higher and lower pointer of each node such that 1) higher pointer points to next higher node. 2) smaller pointer points to next smaller node.
Input Format
head of linked list
Output Format
head of updated linked list
Constraints
1) size of list is [1,10^6] 2) initially higher and smaller pointers are null. 3) all numbers are distinct.
Notice
NA
Example
Input
0 1 3 4 2 6
Output
. 0 1 0 1 2 2 3 4 3 4 6 1 2 3 4 6 .