leetcode

234.回文链表

力扣链接

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