Palindrome Linked List Problem Statement

Determine if a given singly linked list of integers 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 reads the same forwards and backwards, hence it is a palindrome.

Follow Up:

Can you solve the problem in O(N) time complexity and O(1) space complexity iteratively?

Input:

The first line contains an integer 'T' representing the number of test cases. Each test case consists of a single line with elements of the linked list separated by spaces, ending with -1. The -1 is not part of the list.

Output:

For each test case, output “true” or “false” on a new line.

Constraints:

  • 1 <= T <= 10
  • 0 <= L <= 105
  • 1 <= data <= 109 and data != -1

Where L is the number of nodes in the linked list.

Time Limit: 1 sec

Be the first one to answer
Add answer anonymously...
Yodlee Software Engineer Interview Questions
Stay ahead in your career. Get AmbitionBox app
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+

Reviews

4 L+

Interviews

4 Cr+

Salaries

1 Cr+

Users/Month

Contribute to help millions

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

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter