Reverse Linked List II Range Problem

Reverse Linked List II Range Problem — ExecCode Easy DSA Practice

Solve the Reverse Linked List II Range 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 {"left": 2, "right": 4, "values": [1, 2, 3, 4, 5]}; Output 1 4 3 2 5. Input {"left": 1, "right": 5, "values": [1, 2, 3, 4, 5]}; Output 5 4 3 2 1. Input {"left": 1, "right": 1, "values": [1, 2, 3, 4, 5]}; Output 1 2 3 4 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 Range free on ExecCode. Browse DSA problems, topic map, and placement guides.