Search⌘ K
AI Features

Solution: Palindrome Linked List

Understand how to determine if a singly linked list is a palindrome in linear time. Learn to find the midpoint using fast and slow pointers, reverse the second half for comparison, and restore the list's original order without extra space. This lesson helps you implement an efficient palindrome check that maintains data integrity and optimizes time and space complexity.

Statement

Given the head of a linked list, your task is to check whether the linked list is a palindrome or not. Return TRUE if the linked list is a palindrome; otherwise, return FALSE.

Note: The original structure of the linked list must remain unchanged before and after the checking process.

Constraints:

Let n be the number of nodes in a linked list.

  • 11\leq n 500\leq500 ...