FastPrepRotate a Linked List to the Right
Problems/Rotate a Linked List to the Right

Rotate a Linked List to the Right

NVIDIA logoNVIDIA● MediumNEW GRADPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in an NVIDIA phone screen for a new grad role. The report names the well-known list-rotation task and says running time was not required. We chose the direction, what happens for an empty list, and the limits.

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

Given the head head of a singly linked list and a nonnegative integer k, move the final node to the front k times and return the new head.

A complete rotation preserves order. An empty list returns an empty list. The resulting list must terminate; it must not contain a cycle.

Function

rotateRight(head: ListNode, k: int) → ListNode

Examples

Example 1

head = [1,2,3,4,5]k = 2return = [4,5,1,2,3]
head
12345
→
return
45123
Moved or new

The final two nodes become the first two, without reversing them.

Example 2

head = [0,1,2]k = 4return = [2,0,1]
head
012
→
return
201
Moved or new

Four rightward rotations equal one rotation for a three-node list.

Example 3

head = []k = 7return = []
head
empty
return
empty

Rotating an empty list leaves it empty.

Constraints

  • The list contains 0 to 500 nodes.
  • -100 <= Node.val <= 100.
  • 0 <= k <= 2 * 10^9.

More NVIDIA Phone Screen questions

  • Network Layer Execution OrderPHONE SCREEN · Seen Nov 2026
  • Paged KV Cache AccessPHONE SCREEN · Seen Nov 2026
  • Sliding Window Attention over a KV CachePHONE SCREEN · Seen Nov 2026
  • 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

Similar questions at other companies

  • LRU CacheApple · PHONE SCREEN · ONSITE INTERVIEWApple interview questions
  • LRU Cache for Query ResultsAmazon · PHONE SCREEN · ONSITE INTERVIEW
  • Convert a Sorted Linked List to a Balanced BSTMeta · PHONE SCREENMeta interview questions
  • LRU CacheAthenahealth · PHONE SCREEN
  • LRU CacheServiceNow · PHONE SCREEN · ONSITE INTERVIEWServiceNow interview questions
  • Balanced Session ManagerPalantir · PHONE SCREENPalantir interview questions
  • LRU CacheGimlet Labs · PHONE SCREEN
  • LRU CacheBNSF Railway · PHONE SCREENBNSF Railway interview questions
  • Max Frequency TrackerProcol · PHONE SCREEN
  • LRU Cache Operation SequenceCARS24 · PHONE SCREEN

NVIDIA interview experiences

  • NVIDIA Full-Time SWE Onsite Scheduling: 1 Experience
  • NVIDIA OA: What It Tests (2026)
  • NVIDIA DevOps, QA and Infra Intern Interviews: 12 Experiences
  • NVIDIA Ignite Internship OA Experience
  • NVIDIA Software Intern Interview Questions: 9 Experiences
  • 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 ListNode rotateRight(ListNode head, int k) {
        // write your code here
    }
}
Checking account…