Length of longest palindromic list

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)



Input Format

The only argument given is head pointer of the linked list.

Output Format

Return the length of the longest palindrome list.

Constraints

1 <= length of the linked list <= 2000
1 <= Node value <= 100 

For Example

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.
Start solving Length of longest palindromic list on Interview Code Editor
Sign Up
to access hints and editorial solutions for Length of longest palindromic list

Discussion


Loading...
Click here to start solving coding interview questions