693. Reverse Linked List II
0
Easy
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 Print the reversed list.
Input Format
First line contains N,Left and Right.
Second line contains nodes of the Linked List.
Second line contains nodes of the Linked List.
Output Format
Print the reversed Linked List.
Example
Input
5 2 4
1 2 3 4 5
Output
1 4 3 2 5
Constraints
The number of nodes in the list is N.
1 <= n <= 500
-500 <= Node.val <= 500
1 <= left <= right <= N
1 <= n <= 500
-500 <= Node.val <= 500
1 <= left <= right <= N
Loading...
View Submissions
Console