Build and Check a Palindrome Linked List
Updated
Problem statement
You are given an integer array values listing node values from head to tail. Define your own singly linked-list node structure and build the corresponding list. Return true if the list reads the same forward and backward, or false otherwise.
The array is only an input adapter. Practice the list algorithm: locate the middle, reverse the second half, and compare corresponding node values. Once the list has been built, aim to use constant extra space for the comparison. The empty list and a one-node list are palindromes.
The judge checks the returned Boolean; it does not inspect the internal node implementation. The editorial demonstrates the required construction and pointer operations.
Function
isPalindrome(values: int[]) → booleanExamples
Example 1
values = [3,5,5,3]return = trueThe list reads 3,5,5,3 in either direction. Reversing its second half aligns [3,5] with the first half.
Example 2
values = [3,5,7]return = falseThe head and tail values, 3 and 7, do not match.
Constraints
0 <= values.length <= 20000-1000000000 <= values[i] <= 1000000000- The constructed list is singly linked and contains no cycle.
More Omnissa Onsite Interview questions
- Find the CelebrityONSITE INTERVIEW · Seen Sep 2026
- Maximum All-Ones Square Side LengthONSITE INTERVIEW · Seen Sep 2026
- Maximum Subarray SumONSITE INTERVIEW · Seen Sep 2026
- Coin ChangeONSITE INTERVIEW · Seen Jul 2026
- Longest Substring Without Repeating CharactersONSITE INTERVIEW · Seen Jul 2026
- Rotate Array RightONSITE INTERVIEW · Seen Jul 2026
Similar questions at other companies
- Detect a Loop in a Linked ListEPAM · ONSITE INTERVIEWEPAM interview questions
- Merge Two Sorted Linked ListsZS · ONSITE INTERVIEWZS interview questions
- Middle Node Of A Linked ListNVIDIA · ONSITE INTERVIEWNVIDIA interview questions
- Reverse a Singly Linked ListGEP · ONSITE INTERVIEW
- Merge Two Sorted Linked ListsApple · ONSITE INTERVIEWApple interview questions
- Reverse a Singly Linked ListMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
- Reverse Linked ListThe Walt Disney Company · OA · ONSITE INTERVIEWThe Walt Disney Company interview questions
- Detect a Linked-List CycleGoogle · ONSITE INTERVIEWGoogle interview questions
- Detect a Cycle in a Linked ListPeopleStrong · ONSITE INTERVIEWPeopleStrong interview questions
- Reverse a Singly Linked ListBloomberg LP · PHONE SCREEN · ONSITE INTERVIEWBloomberg LP interview questions