摘要:
Givenn, generate all structurally uniqueBST's(binary search trees) that store values 1...n.For example,Givenn= 3, your program should return all 5 unique BST's shown below. 1 3 3 2 1 \ / / / \ \ 3 2 1 1 3 2 / / \ ... 阅读全文
posted @ 2013-09-21 11:34
LEDYC
阅读(194)
评论(0)
推荐(0)
摘要:
Givenn, how many structurally uniqueBST's(binary search trees) that store values 1...n?For example,Givenn= 3, there are a total of 5 unique BST's. 1 3 3 2 1 \ / / / \ \ 3 2 1 1 3 2 / / \ \ 2 1 ... 阅读全文
posted @ 2013-09-21 11:29
LEDYC
阅读(135)
评论(0)
推荐(0)
摘要:
Given a binary tree, return theinordertraversal of its nodes' values.For example:Given binary tree{1,#,2,3}, 1 \ 2 / 3return[1,3,2].Note:Recursive solution is trivial, could you do it iteratively?confused what"{1,#,2,3}"means?> read more on how binary tree is serialized on OJ.---ino 阅读全文
posted @ 2013-09-21 11:17
LEDYC
阅读(138)
评论(0)
推荐(0)
摘要:
Reverse a linked list from positionmton. Do it in-place and in one-pass.For example:Given1->2->3->4->5->NULL,m= 2 andn= 4,return1->4->3->2->5->NULL.Note:Givenm,nsatisfy the following condition:1 ?m?n? length of list.---/** * Definition for singly-linked list. * public c 阅读全文
posted @ 2013-09-21 01:18
LEDYC
阅读(132)
评论(0)
推荐(0)
摘要:
Given a collection of integers that might contain duplicates,S, return all possible subsets.Note:Elements in a subset must be in non-descending order.The solution set must not contain duplicate subsets.For example,IfS=[1,2,2], a solution is:[ [2], [1], [1,2,2], [2,2], [1,2], []]---public class... 阅读全文
posted @ 2013-09-21 01:06
LEDYC
阅读(167)
评论(0)
推荐(0)
浙公网安备 33010602011771号