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...
分类:
其他好文 时间:
2014-11-26 11:26:18
阅读次数:
252
A linked list is given such that each node contains an additional random pointer which could point to any node in the list or null.Return a deep copy ...
分类:
其他好文 时间:
2014-11-26 10:45:07
阅读次数:
205
题意:
Given a linked list, determine if it has a cycle in it.
Follow up:
Can you solve it without using extra space?...
分类:
其他好文 时间:
2014-11-26 01:31:06
阅读次数:
160
Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.分析:我们比较熟悉由一个sorted array生成一个BST,不同的是这里的数据...
分类:
其他好文 时间:
2014-11-25 23:01:58
阅读次数:
213
A linked list is given such that each node contains an additional random pointer which could point to any node in the list or null.Return a deep copy ...
分类:
其他好文 时间:
2014-11-25 22:44:23
阅读次数:
179
Sort a linked list using insertion sort.分析:insertion sort是将当前元素插入到已经排好序的元素的适当位置,时间复杂度为O(n^2)。class Solution {public: ListNode *insertionSortList(Li...
分类:
其他好文 时间:
2014-11-25 20:23:53
阅读次数:
142
Given a linked list, return the node where the cycle begins. If there is no cycle, returnnull.Follow up:Can you solve it without using extra space?分析:...
分类:
其他好文 时间:
2014-11-25 16:24:51
阅读次数:
177
Given a linked list, determine if it has a cycle in it.Follow up:Can you solve it without using extra space?分析:如果一个linked list中有环,那么在用一个快指针和一个慢指针遍历该li...
分类:
其他好文 时间:
2014-11-25 16:09:31
阅读次数:
194
题目描述:
Given a binary tree, flatten it to a linked list in-place.
For example,
Given
1
/ 2 5
/ \ 3 4 6
The flattened tree should look like...
分类:
其他好文 时间:
2014-11-25 12:49:09
阅读次数:
188
Insertion Sort ListSort a linked list using insertion sort.这道题用两个链表做的,这样方便一点。还有新链表头结点我没有存放内容,这样也比较方便,后面返回head1.next就好了 1 /** 2 * Definition for singl....
分类:
其他好文 时间:
2014-11-25 00:09:04
阅读次数:
265