Fold Of Linkedlist

easy
Given a singly linkedlist : l0 -> l1 -> l2 -> l3 -> l4 -> l5 -> l6 ..... -> ln-1 -> ln 
reorder it : l0 -> ln -> l1 -> ln-1 -> l2 -> ln-2 -> l3 -> ln-3 -> ..... 

for more information watch video.

Input Format

1->2->3->4->5->6->7->null

Output Format

1->7->2->6->3->5->4->null

Constraints

0 <= N <= 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
10
5
1
4
6
9
9
6
4
1
5
Output
5 5 1 1 4 4 6 6 9 9 
Previous
Palindrome Linkedlist
Next
Unfold Of Linkedlist

Related Questions