Description

Submission
/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */ class Solution { public: bool isPalindrome(ListNode* head) { vector<int> nums; for(ListNode* ptr = head; ptr != nullptr; ptr = ptr->next) { nums.push_back(ptr->val); } for(int i = 0, j = nums.size() - 1; i < j; ++i ,--j) { if(nums[i] != nums[j]) return false; } return true; } };
