Dsa
Linked List
Medium
Reverse a Subsection of a Linked List
Given the head of a linked list and two integers, start and end, reverse the nodes of the linked list from position start to end. Positions are 1-indexed. Output the modified linked list. Input format: The first line contains an integer n, the number of nodes in the linked list. The second line contains values of the nodes separated by spaces. The third line contains two integers start and end. Output format: The values of the modified linked list in order. Example: Input: 5
1 2 3 4 5
2 4
Output: 1 4 3 2 5
Key concepts
linked_listreversalsubsection
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