234.Palindrome-Linked-List
234. 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?代码
Approach #1 Copy into ArrayList and then Use Two Pointer Technique
Approach #2 Recursive - DFS
Approach #3 Reverse Second Half In-place
Last updated