Katkat

Reverse linked lists, including k-group

NVIDIAData Scientist · HR Screen

Last updated

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.

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.