上一页 1 2 3 4 5 6 7 8 9 10 ··· 18 下一页
  2014年12月2日
摘要: 和上一题类似Best Time to Buy and Sell Stock,这里还是用一个数组存每天股票价格,你有很多次买入卖出的机会,但是每次买入要在前一次卖出前。Say you have an array for which theithelement is the price of a giv... 阅读全文
posted @ 2014-12-02 21:45 higerzhang 阅读(213) 评论(0) 推荐(0) 编辑
摘要: 有一个价格数组,对应的位置代表改天股票的价格,你有一次买入和卖出的机会,你如何使得收益最大化。也就是返回profit。Say you have an array for which theithelement is the price of a given stock on dayi.If you ... 阅读全文
posted @ 2014-12-02 21:38 higerzhang 阅读(455) 评论(0) 推荐(0) 编辑
摘要: 给定一个三角数组,找从上到下的最小和,例如:For example, given the following triangle[ [2], [3,4], [6,5,7], [4,1,8,3]]The minimum path sum from top to bottom is11... 阅读全文
posted @ 2014-12-02 12:28 higerzhang 阅读(257) 评论(0) 推荐(0) 编辑
摘要: 和Pascal's Triangle类似,这里是不需要记录所有的,而是给定一个行号,返回那一行的数据就可以了。例如:For example, givenk= 3,Return[1,3,3,1].所以给0的时候返回[1].题目要求O(k)空间,也就是除了要返回的空间外,其他是常数空间。那就用一个tmp... 阅读全文
posted @ 2014-12-02 11:41 higerzhang 阅读(153) 评论(0) 推荐(0) 编辑
摘要: 这题和上一题Populating Next Right Pointers in Each Node的不一样了,这里要求的是普通的树,难度就比较大了。之前是简单的找到左边的最后,和右边的最左链接就可以了。现在存在的问题是可能右边的左右一层不是在最左或者长度不一等等。 1 / ... 阅读全文
posted @ 2014-12-02 00:51 higerzhang 阅读(769) 评论(0) 推荐(0) 编辑
  2014年12月1日
摘要: 看图就知道想要做什么事了。Given a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *next; }Given the fo... 阅读全文
posted @ 2014-12-01 00:02 higerzhang 阅读(265) 评论(0) 推荐(0) 编辑
  2014年11月30日
摘要: 给定行号,输出如下所示Pascal Triangle(杨辉三角)For example, givennumRows= 5,Return[ [1], [1,1], [1,2,1], [1,3,3,1], [1,4,6,4,1]]思路,想到右上一个构建下一个,构成过程就是上一个的相邻... 阅读全文
posted @ 2014-11-30 22:22 higerzhang 阅读(294) 评论(0) 推荐(0) 编辑
摘要: 给定字符串S和T,S通过删除某些位置的字符得到T的话,就记作一种subSequence。返回总共有几种。Given a stringSand a stringT, count the number of distinct subsequences ofTinS.A subsequence of a ... 阅读全文
posted @ 2014-11-30 21:54 higerzhang 阅读(2158) 评论(0) 推荐(0) 编辑
摘要: 题目:给定一个棵树,将其转换成flattened tree。只有右节点的,类似于链表,且在原址操作。例如:Given 1 / \ 2 5 / \ \ 3 4 6The flattened tree should look l... 阅读全文
posted @ 2014-11-30 18:04 higerzhang 阅读(190) 评论(0) 推荐(0) 编辑
摘要: 和上一题类似,这里是要记录每条路径并返回结果。Given the below binary tree andsum = 22, 5 / \ 4 8 / / \ 11 13 4 ... 阅读全文
posted @ 2014-11-30 10:37 higerzhang 阅读(360) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 8 9 10 ··· 18 下一页