Reverse List

0

0 votes
Easy
Problem

Given a linked list containing n nodes. Two integers x and y are given. Reverse the linked list from xth node to yth node in place i.e. you are not allowed to create a new linked list.
Input Format
First line of each input file contains an integer n. Second line contains n space separated integers. Third line contains two integers x and y.
Output Format
Print the resultant list.
Constraints: All the integers are well with in range.

1 <= x <= y <= n

Sample Input
5
1 2 3 4 5
2 4
Sample Output
1 4 3 2 5
Time Limit: 5
Memory Limit: 256
Source Limit:
Editor Image

?