Linked List 1 - Basic Modules
Use modules packaged in different functions
- Insert a Node in Sorted List
- Remove a Node from Linked List
- Reverse a Linked List
- Merge Two Linked Lists
- Middle of a Linked List
Reverse a linked list from position m to n.
1 ≤ m ≤ n ≤ length of list.
Given 1->2->3->4->null, reorder it to 1->4->2->3->null.
Merge Sort: 时间O(nlogn),局部有序->整体有序,稳定排序
Quick Sort: 时间O(nlogn),最坏O(n^2),整体有序->局部有序,不稳定排序
Given this linked list: 1->2->3->4->5
For k = 2, you should return: 2->1->4->3->5
For k = 3, you should return: 3->2->1->4->5