Zero To DSAZero To DSA
Privacy Policy路FAQ路Report a Bug路Support on Ko鈥慺i
Remove Nth Node From End

Palindrome Linked List

easy
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^5].

Examples

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