/**
- struct ListNode {
- int val;
- struct ListNode *next;
- }; */
class Solution { public: /** * * @param head ListNode类 the head * @return bool布尔型 */
bool isPail(ListNode* head) {
// write code here
if(!head) return false;
vector<int> res;
while(head)
{
res.push_back(head -> val);
head = head -> next;
}
for(int i = 0, j = res.size() - 1; i < j; i ++ , j -- )
{
if(res[i] != res[j])
{
return false;
}
}
return true;
}
};

京公网安备 11010502036488号