Loading

LeetCode 234. 回文链表

 

 1 class Solution {
 2 public:
 3     bool isPalindrome(ListNode* head) {
 4     deque<int> d1, d2;
 5     ListNode* p = head;
 6     while (p != NULL)
 7     {
 8         d1.push_back(p->val);
 9         d2.push_front(p->val);
10         p = p->next;
11     }
12     if (d1 == d2)
13         return true;
14     else
15         return false;
16     }
17 };

 

posted @ 2018-10-20 09:22  拾月凄辰  阅读(129)  评论(0编辑  收藏  举报