Geeksforgeeks

Error

×

Leaderboard

Showing:

Handle | Score |
---|---|

@Ibrahim Nash | 6379 |

@blackshadows | 6329 |

@mb1973 | 5358 |

@Quandray | 5231 |

@akhayrutdinov | 5111 |

@saiujwal13083 | 4510 |

@sanjay05 | 3762 |

@marius_valentin_dragoi | 3522 |

@sushant_a | 3459 |

@verma_ji | 3357 |

@KshamaGupta | 3318 |

Complete Leaderboard | |

Handle | Score |

@ritiksethi21 | 1050 |

@aroranayan999 | 807 |

@RizulBansal | 685 |

@ashishtrehan002 | 538 |

@hemantgarg923 | 528 |

@simrangoyal | 526 |

@ronaldo77 | 520 |

@thanosagain | 505 |

@anishrajan | 505 |

@ssparteek470 | 495 |

@rahul2312 | 491 |

Complete Leaderboard |

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.

**Input:**

The first line of input contains an integer T denoting the number 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.

**User Task**:

The task is to complete the function **maxPalindrome**() which should count the length of longest palindrome in the given list and return it.

**Constraints:**

1 <= T <= 100

1 <= N <= 100

**Example:
Input:**

2

7

2 3 7 3 2 12 24

5

12 4 4 3 14

**Output:**

5

2

**Explanation:
Testcase 1:** 2 -> 3 -> 7 -> 3 -> 2 is the linked list whose nodes leads to a palindrome as 2 3 7 3 2.

Login to report an issue on this page.

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes
Length of longest palindrome in linked list

...