Palindromic Linked List Problem Statement

Given a singly linked list of integers, determine if it is a palindrome. Return true if it is a palindrome, otherwise return false.

Example:

Input:
1 -> 2 -> 3 -> 2 -> 1 -> NULL
Output:
true
Explanation:

The linked list is the same forwards and backwards, hence it is a palindrome.

Constraints:

  • 1 <= T <= 10
  • 0 <= L <= 105
  • 1 <= data <= 109 and data ≠ -1
  • The problem should ideally be solved in O(N) time complexity and O(1) space complexity.

Input:

The first line contains an integer 'T' indicating the number of test cases. For each test case, the line contains the linked list elements separated by spaces, ending with -1 which is not a list element.

Output:

For each test case, output “true” or “false” on a new line corresponding to whether the linked list is a palindrome.
Note:
You do not need to handle any input/output tasks, focus on implementing the function logic.
AnswerBot
4mo

Check if a given singly linked list of integers is a palindrome or not.

  • Traverse the linked list to find the middle element using slow and fast pointers.

  • Reverse the second half of the linked list.

  • Compa...read more

Ponna padma
1mo
True
Help your peers!
Select
Add answer anonymously...

Top Software Engineer Trainee Interview Questions Asked at HSBC Group

Q. What concepts do you know in Cybersecurity?
Q. Write some SQL queries.
Q. Write React code for a login page.
Software Engineer Trainee Interview Questions
Stay ahead in your career. Get AmbitionBox app
play-icon
play-icon
qr-code
Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+

Reviews

10L+

Interviews

4 Cr+

Salaries

1.5 Cr+

Users

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2025 Info Edge (India) Ltd.

Follow Us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter
Profile Image
Hello, Guest
AmbitionBox Employee Choice Awards 2025
Winners announced!
awards-icon
Contribute to help millions!
Write a review
Write a review
Share interview
Share interview
Contribute salary
Contribute salary
Add office photos
Add office photos
Add office benefits
Add office benefits