138. Copy List with Random Pointer

2018-09-07
阅读 2 分钟
2k
A linked list is given such that each node contains an additionalrandom pointer which could point to any node in the list or null.Return a deep copy of the list.

708. Insert into a Cyclic Sorted List

2018-09-07
阅读 3 分钟
4.2k
any single node in the list, and may not be necessarily the smallestvalue in the cyclic list.If there are multiple suitable places for insertion, you may chooseany place to insert the new value. After the insertion, the cycliclist should remain sorted. If the list is empty (i.e., given node is nu...

234. Palindrome Linked List

2018-09-06
阅读 1 分钟
1.5k
Given a singly linked list, determine if it is a palindrome.Example 1: Input: 1->2 Output: false Example 2: Input: 1->2->2->1 Output: true

328. Odd Even Linked List

2018-09-06
阅读 2 分钟
1.7k
Given a singly linked list, group all odd nodes together followed bythe even nodes. Please note here we are talking about the node numberand not the value in the nodes.You should try to do it in place. The program should run in O(1) spacecomplexity and O(nodes) time complexity. Example 1: Input: ...

Intersection of Two Linked Lists

2018-09-05
阅读 2 分钟
1.2k
Write a program to find the node at which the intersection of twosingly linked lists begins. For example, the following two linked lists: A: a1 → a2 {代码...} Notes: If the two linked lists have no intersection at all, return null. Thelinked lists must retain their original structure after the fu...