算法:1.
对root的左子树做处理,让左子树的根节点作为,根节点的右子树,并让右子树作为左子树根节点的右子树的子树2. 递归遍历右子树public void
flatten(TreeNode root) { if(root==null){ return; ...
分类:
其他好文 时间:
2014-05-26 23:39:49
阅读次数:
253
原题地址:https://oj.leetcode.com/problems/copy-list-with-random-pointer/题意:A
linked list is given such that each node contains an additional random pointe...
分类:
编程语言 时间:
2014-05-26 23:16:12
阅读次数:
368
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 o...
分类:
其他好文 时间:
2014-05-26 09:35:28
阅读次数:
266
题目说:Try to do this in one pass
只用一遍遍历的话,p1先走n节点,p2再走,等到p1到达链表尾的时候p2正好在倒数第n+1个上面鸟
/**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* ListNode *next;
* ListNode...
分类:
其他好文 时间:
2014-05-23 01:52:29
阅读次数:
331
Print a linked list from last to first.
分类:
其他好文 时间:
2014-05-22 00:06:27
阅读次数:
258
Delete node in linked list in O(1).
分类:
其他好文 时间:
2014-05-22 00:05:51
阅读次数:
190
Reverse a linked list from positionmton. Do it
in-place and in one-pass.For example:Given1->2->3->4->5->NULL,m=
2 andn= 4,return1->4->3->2->5->NULL.No...
分类:
其他好文 时间:
2014-05-21 19:08:08
阅读次数:
195
Given a sorted linked list, delete all nodes
that have duplicate numbers, leaving onlydistinctnumbers from the original
list.For example,Given1->2->3-...
分类:
其他好文 时间:
2014-05-21 17:51:09
阅读次数:
190
1、
??
Add Two Numbers
You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two num...
分类:
其他好文 时间:
2014-05-21 10:49:10
阅读次数:
221
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 fol...
分类:
其他好文 时间:
2014-05-21 07:18:02
阅读次数:
301