Algorithms
Thursday, November 21, 2013
Reorder List
Given a singly linked list
L
:
L
0
→
L
1
→…→
L
n
-1
→
L
n
,
reorder it to:
L
0
→
L
n
→
L
1
→
L
n
-1
→
L
2
→
L
n
-2
→…
You must do this in-place without altering the nodes' values.
For example,
Given
{1,2,3,4}
, reorder it to
{1,4,2,3}
.
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment