Check Whether a Singly Linked List Is a Palindrome
Company: Omnissa
Role: Software Engineer
Category: Coding & Algorithms
Difficulty: medium
Interview Round: Onsite
Overview: Construct a singly linked list and test whether its values form a palindrome. The exercise requires linear time and constant auxiliary space for the check, encouraging midpoint discovery, partial reversal, careful odd-length handling, and value comparison.
Read the full Omnissa Software Engineer interview experience this question came from
Constraints
- 0 <= values.length <= 1,000,000
- -10^9 <= values[i] <= 10^9
- The empty list is a palindrome.
- After list construction, the check must use O(1) auxiliary space.
Examples
Input: ([1, 2, 3, 2, 1],)
Expected Output: True
Explanation: The values read the same from head to tail and tail to head.
Input: ([1, 2, 2, 3],)
Expected Output: False
Explanation: The first and last values already differ.
Hints
- Use fast and slow pointers to find the midpoint without storing node values separately.
- Reverse the first half while advancing the midpoint pointers, then compare the two halves.