Skip to main content
LeetCode 234, Easy. Topics: Linked List, Two Pointers, Stack, Recursion. View on LeetCode. Generate this problem as a practice environment: tested reference solution, 16 parametrized pytest cases, and a playground notebook:

Problem

Given the head of a singly linked list, return true if it is a palindrome or false otherwise.

Examples

Example 1
Example 2

Constraints

  • The number of nodes in the list is in the range [1, 10^5].
  • 0 <= Node.val <= 9
Follow up: Could you do it in O(n) time and O(1) space?

Solution

Reference implementation from solution.py on GitHub, full suite in test_solution.py:

Complexity

Tags

Grind, NeetCode All.
Last modified on August 25, 2026