less than 1 minute read

Given a singly linked list node whose values are integers, determine whether the linked list forms a palindrome.

Constraints

  • n ≤ 100,000 where n is the length of node

https://binarysearch.com/problems/Palindrome-Linked-List

Examples

Example 1

Input

  • node =

Output

  • answer = True

Explanation

5 -> 3 -> 5 is a palindrome.

Example 2

Input

  • node =

Output

  • answer = True

Explanation

The values of the linked list are the same forwards and backwards.

Solution

Leave a comment