dsa · easy

Palindrome Linked List

GreyOrangeLinked ListTwo PointersFoundation

Return whether the value list head is a palindrome.

Arguments

**Example:** [1,2,2,1]true. [1,2]false.

Constraints

0 <= length <= 10^5 Hidden tests include near-max size for this bound; a slower-than-intended solution TLEs.

Examples

Example 1

Input:
[1,2,2,1]

Expected:
true

Example 2

Input:
[1,2]

Expected:
false

Open in the Dojo editor