FastPrepLinked List Palindrome in Constant Space
Problems/Linked List Palindrome in Constant Space

Linked List Palindrome in Constant Space

NVIDIA logoNVIDIA● EasyINTERNPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in an NVIDIA phone screen for interns. The report asks for a linked-list palindrome check using constant extra space. We chose the node values, what happens for an empty list, whether you may change the list, and the limits. The report mentions follow-ups but does not describe them.

Our version is about 90% the same as the reported question.

Given the head of a singly linked list, return true if its values read the same forwards and backwards. Otherwise, return false.

Use O(1) extra space.

For this exercise, each node has an integer val and a next pointer. The empty list is a palindrome. You may change next pointers; restoring the original list is optional. The examples display the node values as an array in traversal order.

Function

isPalindrome(head: ListNode) → boolean

Examples

Example 1

head = [1,2,2,1]return = true
head
1221

The first and last values are 1, and the two inner values are 2.

Example 2

head = [1,2,3,2,1]return = true
head
12321

The values on both sides of the middle 3 match in reverse order.

Example 3

head = [1,2,3]return = false
head
123

The first value 1 differs from the last value 3.

Example 4

head = []return = true
head
empty

The empty list has no mismatched pair, so it is a palindrome.

Constraints

  • For this exercise, assume the list contains 0 to 500 nodes.
  • For this exercise, assume -10^9 <= node.val <= 10^9.
  • The input is an acyclic singly linked list.

More NVIDIA Phone Screen questions

  • Summarize Server Healthcheck LogsPHONE SCREEN · Seen Oct 2026
  • Hash Partition OffsetsPHONE SCREEN · Seen Oct 2026
  • Filter Paginated Medical RecordsPHONE SCREEN · Seen Oct 2026
  • Least Frequently Used CachePHONE SCREEN · Seen Oct 2026
  • Parallel String Counts with a Custom Hash TablePHONE SCREEN · Seen Oct 2026
  • Simulate a Reference-Counted Smart PointerPHONE SCREEN · Seen Aug 2026
  • Streaming Top-K Frequent ElementsPHONE SCREEN · Seen Aug 2026
  • Merge Multiple Sorted StreamsPHONE SCREEN · Seen Aug 2026
  • LRU Key-Value Cache OperationsPHONE SCREEN · Seen Aug 2026
  • Transformer KV Cache OperationsPHONE SCREEN · Seen Aug 2026

Similar questions at other companies

  • Middle of a Linked ListCisco · PHONE SCREENCisco interview questions
  • Merge Two Sorted ListsIBM · PHONE SCREENIBM interview questions
  • Count Nodes in a ChainApple · PHONE SCREENApple interview questions
  • Detect a Cycle in a Linked ListSalesforce · PHONE SCREENSalesforce interview questions
  • Find the Intersection Node of Two Linked ListsVisa · PHONE SCREENVisa interview questions
  • Reverse a Linked ListMygate · PHONE SCREENMygate interview questions
  • Find the Intersection Node of Two Linked ListsLinkedIn · PHONE SCREENLinkedIn interview questions
  • First Node Two Linked Lists ShareAdobe · PHONE SCREENAdobe interview questions
  • Reverse a Singly Linked ListBloomberg LP · PHONE SCREEN · ONSITE INTERVIEWBloomberg LP interview questions
  • Merge Two Sorted Linked ListsExpedia · PHONE SCREEN · ONSITE INTERVIEWExpedia interview questions

Interview reports that mention this question

  • NVIDIA Software Intern Interview Questions: 9 Experiences

NVIDIA interview experiences

  • NVIDIA DevOps, QA and Infra Intern Interviews: 12 Experiences
  • NVIDIA Ignite Internship OA Experience
  • NVIDIA Ignite SWE Intern OA Questions: 6 Experiences
All NVIDIA interview questionsSee NVIDIA hiring insights
Saved
/**
 * Definition for singly-linked list.
 * public class ListNode {
 *     int val;
 *     ListNode next;
 *     ListNode() {}
 *     ListNode(int val) { this.val = val; }
 *     ListNode(int val, ListNode next) { this.val = val; this.next = next; }
 * }
 */
class Solution {
    public boolean isPalindrome(ListNode head) {
        // Write your code here.
    }
}
Checking account…