Question bank › Linked List
Dsa Linked List Hard

Reverse Nodes in k-Group

You are given a linked list and an integer k. Your task is to reverse the nodes in k-groups. If the number of nodes is not a multiple of k, then the remaining nodes at the end should remain as is. Input format: - The first line contains an integer n (1 <= n <= 1000), the number of nodes in the linked list. - The second line contains n integers representing the values of the nodes. - The third line contains an integer k (1 <= k <= n). Output format: - The linked list after reversing the nodes in k-groups, printed in a single line with values separated by spaces. Example: Input: 5 1 2 3 4 5 3 Output: 3 2 1 4 5

Key concepts

linked_listgroup_reversalmodification

Practise this out loud — free

Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.

🎙 Practise this question now
Part of Praxari's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.