← Back to problemsPalindrome Linked List
EasyData StructuresDescription
Given the head of a singly linked list, return `true` if it is a palindrome (reads the same forward and backward) or `false` otherwise.
**Note:** For this problem, linked lists are represented as arrays for simplicity. The function takes the list as an array and returns a boolean.
Example 1
Input: head = [1,2,2,1]
Output: true
Example 2
Input: head = [1,2]
Output: false
Example 3
Input: head = [1]
Output: true
Constraints
- The number of nodes in the list is in the range [0, 10^5].
- 0 <= Node.val <= 9