Problem Description
Given a singly linked list A, determine if it's a palindrome. Return 1 or 0, denoting if it's a palindrome or not, respectively.
1 <= |A| <= 105
The first and the only argument of input contains a pointer to the head of the given linked list.
Return 0, if the linked list is not a palindrome.
Return 1, if the linked list is a palindrome.
Input 1:
A = [1, 2, 2, 1]
Input 2:
A = [1, 3, 2]
Output 1:
1
Output 2:
0
Explanation 1:
The first linked list is a palindrome as [1, 2, 2, 1] is equal to its reversed form.
Explanation 2:
The second linked list is not a palindrom as [1, 3, 2] is not equal to [2, 3, 1].
NOTE: You only need to implement the given function. Do not read input, instead use the arguments to the function. Do not print the output, instead return values as specified. Still have a question? Checkout Sample Codes for more details.