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 };

 

相关文章:

  • 2022-12-23
  • 2021-11-05
  • 2021-10-19
  • 2021-08-04
  • 2022-02-16
  • 2022-12-23
猜你喜欢
  • 2021-07-21
  • 2021-10-04
  • 2021-09-20
  • 2022-01-22
  • 2022-12-23
  • 2021-12-08
  • 2021-05-03
相关资源
相似解决方案