摘要:
Given a binary tree, flatten it to a linked list in-place.For example,Given 1 / \ 2 5 / \ \ 3 4 6The flattened tree should look like: 1 \ 2 \ 3 \ 4 \ 5 \ 6 思路; 展开后的树其实就是先根遍历的一个结果,不过注意是连... 阅读全文
posted @ 2013-07-16 22:34
冰点猎手
阅读(168)
评论(0)
推荐(0)
摘要:
Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.For example, given n = 3, a solution set is:"((()))", "(()())", "(())()", "()(())", "()()()" backtracking solution:class Solution {private : int n; 阅读全文
posted @ 2013-07-16 22:08
冰点猎手
阅读(212)
评论(0)
推荐(0)
摘要:
Given a string S and a string T, count the number of distinct subsequences of T in S.A subsequence of a string is a new string which is formed from the original string by deleting some (can be none) of the characters without disturbing the relative positions of the remaining characters. (ie, "A 阅读全文
posted @ 2013-07-16 19:44
冰点猎手
阅读(221)
评论(0)
推荐(0)