Zero To DSAZero To DSA
Privacy Policy
Remove Nth Node From End

Palindrome Linked List

medium
Time: O(n)
Space: O(1)

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

Constraints

  • The number of nodes is in the range [1, 10⁵].

Examples

Input: head = [1,2,2,1]
Output: true
Input: head = [1,2]
Output: false