###### brucehb的专栏

Given a singly linked list, determine if it is a palindrome.

Could you do it in O(n) time and O(1) space?

/**
* struct ListNode {
*     int val;
*     ListNode *next;
*     ListNode(int x) : val(x), next(NULL) {}
* };
*/
class Solution {
public:
{
return true;
}
while (p->next && p->next->next)
{
p  = p->next->next;
q = q->next;
}
ListNode *midNode = q;

while (p != NULL)
{
if (p->val != q->val)
{
return false;
}
p = p->next;
q = q->next;
}

revert(midNode);
return true;
}
private:
{
while (p != NULL)
{
ListNode *r = p->next;
p->next = q;
q = p;
p = r;
}

return q;
}
};

#### 234. Palindrome Linked List [easy] (Python)

2016-05-03 19:09:18

#### LeetCode 234: Palindrome Linked List （回文链表）

2015-07-16 22:48:30

#### leetcode 234: Palindrome Linked List

2015-07-14 04:40:25

#### leetcode 234 Palindrome Linked List C++

2016-06-11 15:00:27

2016-09-18 21:45:15

#### 【leetcode】234. Palindrome Linked List（Python & C++）

2017-09-02 20:15:34

2016-03-16 21:19:03

2015-07-29 11:40:29

#### Circular Doubly Linked List 双向循环链表 C++　例子

2013-04-15 10:42:46

2017-04-02 10:04:37