C++ Easy Deque Solution Beats 99.71%
\n# Code\n\n/**\n * Definition for singly-linked list.\n * struct ListNode {\n *     int val;\n *     ListNode *next;\n *     ListNode() : val(0), next(nullptr)
\n# Code\n```\n/**\n * Definition for singly-linked list.\n * struct ListNode {\n *     int val;\n *     ListNode *next;\n *     ListNode() : val(0), next(nullptr) {}\n *     ListNode(int x) : val(x), next(nullptr) {}\n *     ListNode(int x, ListNode *next) : val(x), next(next) {}\n * };\n */\nclass Solution {\npublic:\n    void reorderList(ListNode* head) {\n        deque<ListNode*> q;\n        ListNode* tmp=head;\n        while(tmp!=NULL)\n        {\n            q.push_back(tmp);\n            tmp=tmp->next;\n            q.back()->next=NULL;\n        }\n        q.pop_front();\n        bool f=1;\n        while(!q.empty())\n        {\n            if(!f)\n            {\n                head->next=q.front();\n                q.pop_front();\n            }\n            else\n            {\n                head->next=q.back();\n                q.pop_back();\n            }\n            head=head->next;\n            f=!f;\n        }\n    }\n};\n```
['C++']