Reverse linked lists, including k-group
NVIDIAData Scientist · HR ScreenLast 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.
Solution walkthrough is for members
Get the full walkthrough with reference code and complexity analysis, plus Kitty Coach at 300 messages a day. Hints, the code runner and community answers stay free.