Back to problems Solve on LeetCode → See #876 Middle →

Palindrome Linked List

LeetCode 234 • Easy • Linked Lists

Input: head = [1, 2, 2, 1]  →  Output: true
Find middle (fast/slow), reverse second half, compare first half with reversed second half.

TimeO(n)find mid + reverse + compare
SpaceO(1)pointers only
First: Second:
First half
Second (reversed)
Comparing
First
Second
Ready
Press Play. 1) Find middle (fast/slow). 2) Reverse second half. 3) Compare first half with reversed second.