Associated Course(s):
Sudo Placement [IITs]

Given a linked list, the task is to complete the function **maxPalindrome** which returns an integer denoting the length of the longest palindrome list that exist in the given linked list.

Examples:

```
Input : List = 2->3->7->3->2->12->24
Output : 5
The longest palindrome list is 2->3->7->3->2
Input : List = 12->4->4->3->14
Output : 2
The longest palindrome list is 4->4
```

**Input:**

The first line of input contains an integer T denotingo the no of test cases. Then T test cases follow. The first line of each test case contains an integer N denoting the size of the linked list . Then in the next line are N space separated values of the given linked list.

**Output:**

For each test case output will be the required max length of the palindrome present in the given linked list.

**Constraints:**

1<=T<=100

1<=N<=100

**Example(To be used only for expected output):
Input:**

2

7

2 3 7 3 2 12 24

5

12 4 4 3 14

5

2

Author: Shubham Joshi 1

blackshadows | 242 |

layman_brother | 234 |

xmyqsh | 220 |

Adarsh Trivedi | 205 |

hanuman001 | 200 |

blackshadows | 724 |

xmyqsh | 561 |

aman19 | 402 |

r0c2048 | 360 |

mb1973 | 335 |

akhayrutdinov | 5005 |

Ibrahim Nash | 4875 |

Quandray | 4338 |

sanjay05 | 3668 |

blackshadows | 3228 |

Login to report an issue on this page.