Definition at line 17 of file main.cpp.
◆ oddEvenList()
Definition at line 20 of file main.cpp.
21 {
22 if (!head)
23 return NULL;
24 list<ListNode*> odd;
25 list<ListNode*> even;
27 bool is_odd = true;
28 while (current != NULL)
29 {
30 if (is_odd)
31 odd.push_back(current);
32 else
33 even.push_back(current);
34 current = current->
next;
35 is_odd = !is_odd;
36 }
37
38 current = head;
39 auto it = odd.begin();
40 it++;
41 for (; it != odd.end(); ++it)
42 {
44 current = current->
next;
45 }
46 it = even.begin();
47 for (; it != even.end(); ++it)
48 {
50 current = current->
next;
51 }
53 return head;
54 }
Definition for singly-linked list.
References ListNode::next.
The documentation for this class was generated from the following file: