PracHub
QuestionsPremiumLearningGuidesCheatsheetNEWCoaches
|Home/Coding & Algorithms/NVIDIA

Reverse linked lists, including k-group

Last updated: Mar 29, 2026

Quick Overview

This question evaluates understanding of linked list manipulation including pointer operations, in-place reversal techniques, recursion and stack-depth considerations, cycle detection, and time/space complexity analysis.

  • hard
  • NVIDIA
  • Coding & Algorithms
  • Data Scientist

Reverse linked lists, including k-group

Company: NVIDIA

Role: Data Scientist

Category: Coding & Algorithms

Difficulty: hard

Interview Round: HR Screen

Reverse a singly linked list. Provide iterative O(1)-space and recursive solutions, analyze time/space, and handle edge cases: empty list, one node, very long list (stack depth), and a sublist reversal between positions m and n. Then extend to reverse nodes in k groups with O(1) extra space, preserving leftover tail order. Explain how you would detect and reject cyclic lists before reversing.

Quick Answer: This question evaluates understanding of linked list manipulation including pointer operations, in-place reversal techniques, recursion and stack-depth considerations, cycle detection, and time/space complexity analysis.

Related Interview Questions

  • Return all file paths via DFS - NVIDIA (easy)
  • Implement a disk space manager with eviction - NVIDIA (medium)
  • Implement short algorithms on logs, grids, and strings - NVIDIA (hard)
  • Implement encode/decode for list of strings - NVIDIA (easy)
  • Solve small string and API tasks - NVIDIA (medium)
NVIDIA logo
NVIDIA
Oct 13, 2025, 9:49 PM
Data Scientist
HR Screen
Coding & Algorithms
2
0

Singly Linked List Reversal — Variants and Edge Cases

You are given a standard singly linked list with nodes of the form:

  • Node fields: value, next
  • Head pointer may be null (empty list).
  • Assume 1-indexed positions for m and n.

Implement and analyze the following:

A) Reverse Entire List

  1. Provide an iterative in-place solution that uses O(1) extra space.
  2. Provide a recursive solution.
  3. Analyze time and space complexity of both.
  4. Explicitly handle edge cases: empty list, single-node list, and very long lists (stack depth considerations for recursion).

B) Reverse a Sublist [m, n]

  • Reverse the nodes from position m to n (inclusive), in-place, and return the head. Assume 1 ≤ m ≤ n ≤ length of list.

C) Reverse Nodes in k-Groups

  • Reverse the list in contiguous groups of size k using O(1) extra space. If the final group has fewer than k nodes, leave that tail group as-is.

D) Cycle Detection Before Reversal

  • Explain and implement how to detect a cycle in the list and reject (do not attempt to reverse) if a cycle is present.

You may use pseudo-code or code in a language of your choice.

Solution

Show

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More NVIDIA•More Data Scientist•NVIDIA Data Scientist•NVIDIA Coding & Algorithms•Data Scientist Coding & Algorithms
PracHub

Master your tech interviews with 7,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.