92. Reverse Linked List II
Algorithm:
- find (m-1)th node
- reverse (n-m+1) nodes
Reverse a linked list from position m to n. Do it in one-pass.
Note: 1 ≤ m ≤ n ≤ length of list.
Example:
1 | Input: 1->2->3->4->5->NULL, m = 2, n = 4 |
Soulution:
1 | class Solution: |