Dsa
Linked List
Medium
Rhythmic Block Reversal
Given a linked list and an initial block size of 1, reverse the first block. Then, increment the block size to 2 and reverse the next 2 nodes. Then, increment to 3 and reverse the next 3 nodes, and so on. If the remaining nodes are fewer than the current block size, reverse all of them. Return the modified list.
Example:
Input: 1 2 3 4 5 6 7 8 9 10
- Block 1 (size 1): [1] -> [1]
- Block 2 (size 2): [2, 3] -> [3, 2]
- Block 3 (size 3): [4, 5, 6] -> [6, 5, 4]
- Block 4 (size 4): [7, 8, 9, 10] -> [10, 9, 8, 7]
Output: 1 3 2 6 5 4 10 9 8 7
Key concepts
linked_listin-placegrouping
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