Palindrome Linked List Visualization & Animation

Checks if a linked list is a palindrome by finding the middle, reversing the second half, and comparing.

## What is it? Check whether a singly linked list is a palindrome — reads the same forwards and backwards. Achieved in O(n) time and O(1) space using the find-middle + reverse-half technique. ## How it works 1. Find the middle of the list (fast/slow pointers) 2. Reverse the second half of the list in-place 3. Compare the first half and the reversed second half node by node 4. (Optional) Restore the original list by reversing the second half back ## When to use - Palindrome validation on a singly linked list where random access is unavailable - Problems where you cannot use extra space (ruling out a stack or array approach) ## Key Points - O(n) time, O(1) space — the key insight is to reverse in-place - Destroying the list structure can be avoided by restoring after comparison - Using a stack is simpler but O(n) space

Category: algorithms

Difficulty: beginner

Time Complexity: O(n)

Space Complexity: O(1)

Palindrome Linked List

beginner

Checks if a linked list is a palindrome by finding the middle, reversing the second half, and comparing.

Initializing
null1384722156249211NULLslowfastprevcurrnextleftrighthead
Start: slow = node-0 (1), fast = node-0 (1). Find the middle using fast/slow pointers.