class Solution {
public:
bool isPalindrome(ListNode* head) {
vector<int> res;
while (head) {
res.push_back(head->val);
head = head->next;
}
int i=0, j= res.size()-1;
while (i<=j) {
if(res[i]!=res[j]) return false;
i+=1; j-=1;
}
return true;
}
};