Given a linked list of integers. Find and return the length of the longest palindrome list that exists in that linked list.
Note: A palindrome list is a list that reads the same backward and forward.
Expected memory complexity : O(1)
The only argument given is head pointer of the linked list.
Return the length of the longest palindrome list.
1 <= length of the linked list <= 2000 1 <= Node value <= 100
Input 1: 2 -> 3 -> 3 -> 3 Output 1: 3 Input 2: A = 2 -> 1 -> 2 -> 1 -> 2 -> 2 -> 1 -> 3 -> 2 -> 2 Output 2: 5
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 doubt? Checkout Sample Codes for more details.