# LeetCode 92. Reverse Linked List II

## Description

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
``````

# LeetCode 86. Partition List

## Description

Partition List

Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x.

You should preserve the original relative order of the nodes in each of the two partitions.

Example:

``````Input: head = 1->4->3->2->5->2, x = 3
Output: 1->2->2->4->3->5
``````

# LeetCode 82. Remove Duplicates From Sorted List II

## Description

Remove Duplicates from Sorted List II

Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list.

Example 1:

``````Input: 1->2->3->3->4->4->5
Output: 1->2->5
``````

Example 2:

``````Input: 1->1->1->2->3
Output: 2->3
``````

# LeetCode 61. Rotate List

## Description

Rotate List

Given a linked list, rotate the list to the right by `k` places, where `k` is non-negative.

Example 1:

``````Input: 1->2->3->4->5->NULL, k = 2
Output: 4->5->1->2->3->NULL
Explanation:
rotate 1 steps to the right: 5->1->2->3->4->NULL
rotate 2 steps to the right: 4->5->1->2->3->NULL
``````

Example 2:

``````Input: 0->1->2->NULL, k = 4
Output: 2->0->1->NULL
Explanation:
rotate 1 steps to the right: 2->0->1->NULL
rotate 2 steps to the right: 1->2->0->NULL
rotate 3 steps to the right: 0->1->2->NULL
rotate 4 steps to the right: 2->0->1->NULL
``````

# LeetCode 25. Reverse Nodes in k-Group

Reverse Nodes in k-Group

## Description

Given a linked list, reverse the nodes of a linked list k at a time and return its modified list. k is a positive integer and is less than or equal to the length of the linked list. If the number of nodes is not a multiple of k then left-out nodes in the end should remain as it is. You may not alter the values in the nodes, only nodes itself may be changed.

Only constant memory is allowed. For example,

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`

# LeetCode 23. Merge K Sorted Lists

Merge k Sorted Lists

## Description

Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.

`k`个有序链表合并为一个链表

# LeetCode 21. Merge Two Sorted Lists

Merge Two Sorted Lists

## Description

Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists.

# LeetCode 19. Remove Nth Node From End of List

Remove Nth Node From End of List

## Description

Given a linked list, remove the nth node from the end of list and return its head.

``````For example,
Given linked list: 1->2->3->4->5, and n = 2.
After removing the second node from the end, the linked list becomes 1->2->3->5.
``````

Note: Given n will always be valid. Try to do this in one pass.

Programer

ChengDu·China
-