Definition at line 17 of file main.cpp.
◆ reorderList()
| void Solution::reorderList |
( |
ListNode * |
head | ) |
|
|
inline |
Definition at line 20 of file main.cpp.
21 {
22 if (head == nullptr)
23 return;
24 deque<int> val_deque;
26 while (current != nullptr)
27 {
28 val_deque.push_back(current->
val);
29 current = current->
next;
30 }
31 current = head;
32 while (!val_deque.empty())
33 {
35 val_deque.pop_back();
36 current = current->
next;
37 if (!val_deque.empty())
38 {
40 val_deque.pop_front();
41 current = current->
next;
42 }
43 }
44 current->
next =
nullptr;
45 return;
46 }
Definition for singly-linked list.
References ListNode::next, and ListNode::val.
The documentation for this class was generated from the following file: