因为实验室项目好久没刷题了。从今天开始重新开始刷题。 Given a set of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers...
分类:
其他好文 时间:
2014-07-16 23:04:15
阅读次数:
166
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-16 21:00:49
阅读次数:
208
Given a digit string, return all possible letter combinations that the number could represent.A mapping of digit to letters (just like on the telephon...
分类:
其他好文 时间:
2014-07-16 20:50:06
阅读次数:
137
Evaluate the value of an arithmetic expression inReverse Polish Notation.Valid operators are+,-,*,/. Each operand may be an integer or another express...
分类:
其他好文 时间:
2014-07-16 20:44:52
阅读次数:
158
Sort a linked list inO(nlogn) time using constant space complexity.题解:实现一个链表的归并排序即可。主要分为三部分:1.找到中点并返回的函数findMiddle;2.归并函数merge;3.排序函数sortList。数组的findM...
分类:
其他好文 时间:
2014-07-14 20:00:56
阅读次数:
182
Sort a linked list using insertion sort.题解:实现链表的插入排序。要注意的地方就是,处理链表插入的时候尽量往当前游标的后面插入,而不要往前面插入,后者非常麻烦。所以每次利用kepeler.next.val和head.val比较大小,而不是kepeler.val...
分类:
其他好文 时间:
2014-07-14 17:47:19
阅读次数:
207
Givennpoints on a 2D plane, find the maximum number of points that lie on the same straight line.题解:思路比较简单,每条直线都可以表示为y=kx+b,所以对于任意三点,如果它们共线,那么它们中任意两点的...
分类:
其他好文 时间:
2014-07-14 10:02:12
阅读次数:
187
Given amxnmatrix, if an element is 0, set its entire row and column to 0. Do it in place.题解:因为题目要求原地算法,所以我们只能利用矩阵第一行和第一列存放置零信息。首先遍历第一行和第一列,看他们是否需要全部置零...
分类:
其他好文 时间:
2014-07-08 23:58:29
阅读次数:
422
Given an integern, generate a square matrix filled with elements from 1 ton2in spiral order.For example,Givenn=3,You should return the following matri...
分类:
其他好文 时间:
2014-07-08 23:54:39
阅读次数:
407
题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=2795
~~~~
开始学习数据结构,从简单的开始吧,刷题累了就写解题报告,哈哈,沸腾吧,Segment tree!
~~~~
大致题意:一块 h*w的广告牌,蓝后就是n块1*wi大小的广告,依次贴到广告牌上,而且总是贴到最左上角,问贴完所有广告后所占的高度是多少?
#include
#...
分类:
其他好文 时间:
2014-07-06 00:35:13
阅读次数:
245