92.Reverse-Linked-List-II

92. Reverse Linked List II

题目地址

https://www.lintcode.com/problem/reverse-linked-list-ii/

https://leetcode.com/problems/reverse-linked-list-ii/

题目描述

Reverse a linked list from position m to n. Do it in one-pass.

Note: 1 ≤ m ≤ n ≤ length of list.

Example:
Input: 1->2->3->4->5->NULL, m = 2, n = 4
Output: 1->4->3->2->5->NULL

代码

Approach #1 Iteration

Approach #2 Recursion

Last updated

Was this helpful?