Palindrome Linked List

Easy

Company Tags

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

A palindrome is a sequence that reads the same forward and backward.

Example 1:

Input: head = [1,2,3,2,1]

Output: true

Example 2:

Input: head = [2,2]

Output: true

Example 3:

Input: head = [2,1]

Output: false

Constraints:

  • 1 <= Length of the list <= 100,000.
  • 0 <= Node.val <= 9

Follow up: Could you do it in O(n) time and O(1) space?



Company Tags

Please upgrade to NeetCode Pro to view company tags.

head =