![]() |
palindrome-linked-list 1.0.0
Palindrome Linked List
|
Easy
Given the head of a singly linked list, return true if it is a palindrome or false otherwise.
Example 1:
Input: head = [1,2,2,1] Output: true
Example 2:
Input: head = [1,2] Output: false
Constraints:
The number of nodes in the list is in the range [1, 105]. 0 <= Node.val <= 9
Solution loads pointers to list nodes into double-ended queue. Then, it compares both top and bottom values at once to establish whether the input is in fact a palindrome.