/**
* 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>obj;
while(head)
{
obj.push_back(head->val);
head=head->next;
}
int i=0;
int j=obj.size()-1;
while(i<j)
{
if(obj[i]!=obj[j])
{
return false;
}
i++;
j--;
}
return true;
}
};
LeetCode:234. 回文链表
猜你喜欢
转载自blog.csdn.net/dosdiosas_/article/details/106247089
今日推荐
周排行