Palindrome Linked List
Problem Statement
You are given the head of a singly linked list. Return true if the values read the same forwards and backwards (a palindrome), and false otherwise.
Follow-up: can you do it in O(N) time and O(1) extra space?
head, the first node of a singly linked list.
true if the list's values form a palindrome, otherwise false.
Read backwards it is still 1, 2, 2, 1.
Backwards it is 2, 1, which is different.
- • The list has between 1 and 10^5 nodes.
- • 0 ≤ Node.val ≤ 9
- • Follow-up: O(N) time and O(1) extra space.
Pattern Recognition Clues
Recognising these key signals in the problem description immediately identifies the pattern:
Approach Complexity Ladder
Copy values into a vector, compare from both ends
Slow/fast to the middle, reverse the back half in place, compare, reverse it back
The trouble with a linked list is that we can't walk it backwards. An array doesn't have that problem. Copy all values into a vector, then use two pointers: one at the start, one at the end, moving inward and comparing.
Recognition rule for this sub-pattern:
Unlock Complete Visual Walkthrough & Optimal C++
The interactive animated dry-run player, optimized C++ implementation, state invariant derivations, and edge-case breakdown for this question are part of Brute2Best Pro. The anchor question of every sub-pattern is completely free.
First anchor question per pattern, Part 1 LLD & Module 1 C++ basics are 100% Free forever.
How this concept connects to System Design & C++ Systems
Top engineering interviews test whether you understand how algorithms like Linked List — Fast & Slow translate into production architectures and low-level memory mechanics.
Foundations: Object-Oriented Principles in C++23
Class invariants, pure virtual interfaces, and RAII smart pointers.
Food Delivery System (Zomato Architecture)
Real-world machine coding application of algorithms and design patterns.
Pointers vs References Deep Dive
Pointer arithmetic and memory layout under the hood.
Virtual Method Table (vtable) & Memory Layout
Polymorphism, vptr overhead, and multiple inheritance in memory.