Follow up for problem "Populating Next Right Pointers in Each Node".
What if the given tree could be any binary tree? Would your previous solution still work?
Note:
You may only use constant ...
分类:
其他好文 时间:
2015-01-14 17:55:09
阅读次数:
199
Sort a linked list in O(n log n)
time using constant space complexity.
#include
#include
typedef struct ListNode{
int val;
struct ListNode *next;
}ListNode;
ListNode *mergesort(ListNode *...
分类:
其他好文 时间:
2015-01-13 17:42:46
阅读次数:
113
【题目】
Sort a linked list in O(n log n)
time using constant space complexity.
【分析】
单链表适合用归并排序,双向链表适合用快速排序。本题可以复用Merge Two Sorted Lists方法
【代码】
/*********************************
* 日期:2015-01-1...
分类:
其他好文 时间:
2015-01-13 00:10:40
阅读次数:
184
之前在使用struts的时候是使用MyEclipse,所以有很多东西是不需要自己配置的,也就没有注意那么多,现在使用Eclipse,发现有很多东西既熟悉又陌生。对于constant标签,我似乎没有怎么使用,最主要就是使用<constantname="struts.i18n.reload"value="true"/>,现在就全面..
分类:
其他好文 时间:
2015-01-12 19:34:07
阅读次数:
167
AntsDescriptionAn army of ants walk on a horizontal pole of length l cm, each with a constant speed of 1 cm/s. When a walking ant reaches an end of th...
分类:
其他好文 时间:
2015-01-10 17:55:32
阅读次数:
149
Given a linked list, swap every two adjacent nodes and return its head.
For example,
Given 1->2->3->4, you should return the list as 2->1->4->3.
Your algorithm should use only constant space. Y...
分类:
其他好文 时间:
2015-01-10 13:57:24
阅读次数:
119
-One such related pair of patterns is the concept
of an executor service that manages tasks and that of a thread pool that services tasks in
an efficient way.
-The new Callable interface, whic...
分类:
编程语言 时间:
2015-01-09 00:18:47
阅读次数:
365
题目:Sort a linked list inO(nlogn) time using constant space complexity.代码:oj 测试通过Runtime:372 ms 1 # Definition for singly-linked list. 2 # class ListNo...
分类:
编程语言 时间:
2015-01-08 19:37:40
阅读次数:
195
Design a stack that supports push, pop, top, and retrieving the minimum element in constant time.push(x) -- Push element x onto stack.pop() -- Removes...
分类:
其他好文 时间:
2015-01-08 12:51:24
阅读次数:
114