234. Palindrome Linked List
# Easy
Method 1:
Two pointers, one list to store the first half elements in order.
1 -> 2 -> 1
and 1 -> 2 -> 2 -> 1
are palindrome linked list.
Two cases: the length of the linked list is odd or even.
Method 2:
slow, fast pointers. When slow goes to the middle of the list, reverse the last half of list, then compare front to end one by one.
Time = , Space = , How to reduce space to ?
Last updated