## wangzq的专栏

Total Accepted: 1116 Total Submissions: 4295 My Submissions Question Solution
Given a singly linked list, determine if it is a palindrome.
Could you do it in O(n) time and O(1) space?
Hide Tags Linked List Two Pointers
【解题思路】
1、遍历链表，快慢指针，找到链表后半部分。
3、然后比较前半部分和后半部分的val值。

Java AC

/**
* public class ListNode {
*     int val;
*     ListNode next;
*     ListNode(int x) { val = x; }
* }
*/
public class Solution {
return true;
}
ListNode fast = slow.next;
while (fast != null && fast.next != null && fast.next.next != null){
slow = slow.next;
fast = fast.next.next;
}
ListNode p = slow.next;
ListNode q;
ListNode end = null;
while (p != null) {
q = p.next;
p.next = end;
end = p;
p = q;
}
while (head != null && end != null) {
return false;
}
end = end.next;
}
return true;
}
}

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

2015-07-16 22:48:30

2016-03-16 21:19:03

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

2017-09-02 20:15:34

#### leetcode141&234

2017-01-13 19:51:43

2015-07-29 11:40:29

#### leetcode 234: Palindrome Linked List

2015-07-14 04:40:25

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

2016-06-11 15:00:27

#### LeetCode 234 Palindrome Linked List

2018-05-26 16:02:28

#### leetcode判断回文

2018-03-08 23:32:05

#### 【leetcode】Python实现-234.回文链表

2018-06-10 13:11:45