Back to problems

Reverse linked lists, including k-group

Algorithm · NVIDIA · Hard

Implement a set of linked-list operations on a singly linked list. Each node stores an integer val and a next pointer. In the examples, a list is shown as an array of node values in order. Your implementation must address the following operations and analyses: Whole-list reversal. Provide two implementations of reverseList(head): an iterative version that uses $$O(1)$$ extra space; a recursive version. State the time and space complexity of each version. Sublist reversal.…

Checking your access…