摘要:
给定行号,输出如下所示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
阅读(303)
评论(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
阅读(2167)
评论(0)
推荐(0)
摘要:
题目:给定一个棵树,将其转换成flattened tree。只有右节点的,类似于链表,且在原址操作。例如:Given 1 / \ 2 5 / \ \ 3 4 6The flattened tree should look l... 阅读全文
posted @ 2014-11-30 18:04
higerzhang
阅读(196)
评论(0)
推荐(0)
摘要:
和上一题类似,这里是要记录每条路径并返回结果。Given the below binary tree andsum = 22, 5 / \ 4 8 / / \ 11 13 4 ... 阅读全文
posted @ 2014-11-30 10:37
higerzhang
阅读(367)
评论(0)
推荐(0)
摘要:
题目:给定一颗数,以及一个数sum。判断是否存在从树到叶节点的和等于sum。例如:Given the below binary tree andsum = 22, 5 / \ 4 8 / / \ ... 阅读全文
posted @ 2014-11-30 09:53
higerzhang
阅读(281)
评论(0)
推荐(0)
摘要:
题目:返回根节点到最近的叶子节点的距离。例如:{1,2},其中2是1的左子树,1的右子树为空,2为叶子节点,那么此时返回2.如果用简单的递归,以为是返回左右两边的最小值加1,那么上面那个case就错了,因为如果返回左右两边最小值加1的话,上面1的右边是0,所以返回1,但我们想要的是2.所以要另外注意... 阅读全文
posted @ 2014-11-30 00:07
higerzhang
阅读(219)
评论(0)
推荐(0)
浙公网安备 33010602011771号