//直接改变val的值就可以了
#include<vector>
using namespace std;
class Solution {
public:
void reorderList(ListNode* head) {
vector<int> q;
ListNode* temp = head;
while (head != NULL) {
q.emplace_back(head->val);
head = head->next;
}
int n = q.size() - 1;
int m = 0;
int i = 0;
head = temp;
while (n - m >= 0) {
if (i == 0) {
temp->val = q[m];
m++;
i++;
} else {
temp->val = q[n];
n--;
i--;
}
temp = temp->next;
}
}
};