Reverse Linked List II Problem
Reverse Linked List II Problem — ExecCode Easy DSA Practice
Solve the Reverse Linked List II problem on ExecCode. Free online easy DSA practice in Linked List. Write and run code in Java, C++, Python — no signup required to run.
Problem description
Description You are given the head of a singly linked list and two integers left and right where left <= right, reverse the nodes of the list from position left to position right, and return the reversed list.
Examples
Input {"values": [1, 2, 3, 4, 5], "left": 2, "right": 4}; Output 1 4 3 2 5. Input {"values": [5, 4, 3, 2, 1], "left": 1, "right": 5}; Output 1 2 3 4 5. Input {"values": [3, 5, 1, 2], "left": 2, "right": 4}; Output 3 2 1 5
Constraints
The number of nodes in the list is n. 1 <= n <= 500 -500 <= Node.val <= 500 1 <= left <= right <= n
Practice Reverse Linked List II free on ExecCode. Browse DSA problems, topic map, and placement guides.