Skip to content

Latest commit

 

History

History
38 lines (24 loc) · 667 Bytes

0234-palindrome-linked-list.adoc

File metadata and controls

38 lines (24 loc) · 667 Bytes

234. Palindrome Linked List

{leetcode}/problems/palindrome-linked-list/[LeetCode - Palindrome Linked List^]

使用快慢指针将链表切成两段,然后对后面的一段进行反转,再逐个比较两个子链。

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

Example 1:

Input: 1->2
Output: false

Example 2:

Input: 1->2->2->1
Output: true

Follow up:

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

link:{sourcedir}/_0234_PalindromeLinkedList.java[role=include]