Given the head of a singly linked list and two 1-based positions m and n with m <= n, reverse the nodes from position m to n inclusive and return the list. The list is given as an array; return the resulting array. Input: '[list], m, n'.
Input: '[list], m, n'.
Output: Array — the list after reversing the segment.
Input: [1,2,3,4,5], 2, 4
Output: [1,4,3,2,5]
Explanation: Positions 2..4 reversed.Input: [5], 1, 1
Output: [5]
Explanation: Single node.Input: [1,2,3,4,5], 1, 5
Output: [5,4,3,2,1]
Explanation: Whole list reversed.1<=n<=5001<=m<=n<=list length