92 Reverse Linked List II – Medium
Problem:
Reverse a linked list from position m to n. Do it in-place and in one-pass.
For example: Given 1->2->3->4->5->NULL, m = 2 and n = 4,
return 1->4->3->2->5->NULL.
Note: Given m, n satisfy the following condition: 1 ≤ m ≤ n ≤ length of list.
Thoughts:
Pointer modification. The best strategy to deal with linked list, pointer modification problem is to draw the data structure on a paper. Plus, be careful to take care of edge case. Adding a fake head is efficient to deal with edge cases most of the time.
Solutions:
Last updated