Problem Description:Sort a linked list inO(nlogn) time using constant space complexity.Solution: 1 public ListNode sortList(ListNode head) { 2 ...
分类:
其他好文 时间:
2014-07-07 16:48:00
阅读次数:
238
Problem Description:Given a linked list, determine if it has a cycle in it.Follow up:Can you solve it without using extra space?Solution: 1 public bo....
分类:
其他好文 时间:
2014-07-07 16:08:01
阅读次数:
151
Problem Description:Given a stringsand a dictionary of wordsdict, determine ifscan be segmented into a space-separated sequence of one or more diction...
分类:
其他好文 时间:
2014-07-07 16:02:11
阅读次数:
219
Given a stringsconsists of upper/lower-case alphabets and empty space characters' ', return the length of last word in the string.If the last word doe...
分类:
其他好文 时间:
2014-07-07 15:30:23
阅读次数:
169
原题: URAL 1091 http://acm.timus.ru/problem.aspx?space=1&num=1091题意:要求找出K个不同的数字使他们有一个大于1的公约数,且所有的数字都不能大于一个指定的数字S。解法:可以考虑每个S内的素数,此素数和它的所有倍数构成一个集合,则可以在这些集...
分类:
其他好文 时间:
2014-07-02 00:37:32
阅读次数:
253
Weekly golfers will find a bag that gives them enough space to do a lot of tees, balls, sticks, and whatever he deems necessary for the golf course. P...
分类:
其他好文 时间:
2014-06-30 20:52:39
阅读次数:
258
java虚拟机运行一般都有一个内存界限,超过这个界限,就会报outofmemory。这个时候一般都是存在内存泄漏。解决内存泄漏问题,窃以为分为两个步骤:分析应用程序是否真的有内存泄漏,找到内存泄漏的地方。这两个步骤都不是一般意义上的调试,直接打log,断点调试都不是太给力。动脑筋想一想,内存问题应该在很多地方上都会出现,这么常见的问题应该是有工具的。android现在更可以说是一个生态系统,当然也...
分类:
移动开发 时间:
2014-06-30 20:12:31
阅读次数:
251
Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length.
Do not allocate extra space for another array, you must do this in place with...
分类:
其他好文 时间:
2014-06-30 17:22:13
阅读次数:
196
①push_heap算法
下面是push_heap算法的实现细节。该函数接收两个迭代器,用来表现一个heap底部容器(vector)的头尾,并且新元素已经插入到底部的最尾端。
template
inline void push_heap(RandomAccessIterator first,RandomAccessIterator last)
{
//注意,此函数被调用时,新...
分类:
其他好文 时间:
2014-06-30 09:25:57
阅读次数:
239
题目链接:http://poj.org/problem?id=2442
题目大意:给出一个m*n的矩阵,从每一行中取出一个数相加,能得到n^m个不同的结果,要求输出其中前n项。
建立一个以n元数组为底层数组的堆,在这里,利用stl中的make_heap,pop_heap,push_heap等函数解决。
1.将第一组数据输入arr1数组,升序排序。
2.将接下来的数据输入到arr2数组中,并...
分类:
其他好文 时间:
2014-06-29 23:25:31
阅读次数:
259