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.
Be the first one to answer
Add answer anonymously...
Top HSBC Group Software Engineer Trainee interview questions & answers
Popular interview questions of Software Engineer Trainee
Top HR questions asked in HSBC Group Software Engineer Trainee
>
HSBC Group Software Engineer Trainee Interview Questions
Stay ahead in your career. Get AmbitionBox app
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
Get AmbitionBox app