15% off all plans & roadmaps Use code
See plansLeetCode 234 · Solution & editorial
Given the head of a singly linked list, return true if it is a palindrome or false otherwise.
Palindrome Linked List is a Linked List Manipulation Patterns problem, in the In-place Reversal subpattern. The pattern covers in-place reversal, merging sorted lists, reordering, and intersection detection
Master in-place linked list reversal including full reversal, partial reversal, and k-group reversal techniques.
The reference solution runs in O(n) time and O(1) space.
Palindrome Linked List has been reported in interviews at Microsoft, Facebook, Amazon, Adobe, Capital One, Google, Oracle, Bloomberg.
The full editorial is part of Pro
It explains the core insight, the complexity analysis and the common mistakes, with a worked solution.
Palindrome Linked List is a Linked List Manipulation Patterns problem, in the In-place Reversal subpattern. Once the approach above makes sense, write it yourself and then work through the neighbouring problems that reuse it.