You are given the head of a singly linked list.
Your task is to determine whether the values in the linked list form a palindrome.
Note that:
Return true if the linked list is a palindrome, and false otherwise.
1 → 2 → 3 → 2 → 1 → null
True
The values read the same forwards and backwards: 1, 2, 3, 2, 1.
1 → 2 → 3 → 4 → null
False
The values 1, 2, 3, 4 do not read the same forwards and backwards.
1 → null
True
A single-node linked list is always a palindrome.
1 → 2 → 3 → 2 → 1 → null
True