SYNOPSYS Hiring | On Campus OA (2023) | Reverse Nodes in K-Group

Question · Posted Jun 2026

Problem Statement Given the head of a linked list, reverse the nodes of the list k at a time and return the modified list. Nodes should be reversed in groups of size k. If the number of remaining nodes is less than k, leave them unchanged. You may not alter the values inside the nodes; only the links between nodes can be changed. The solution must use O(1) extra space. Constraints 1 <= k <= n <= 5000 0 <= ...

The full answer & interview discussion are available to premium members.

Log in Create a free account