摘要: Given a binary tree, find its minimum depth.The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node.public class Solution { public int minDepth(TreeNode root) { int depth = 0; if(root != null){ if(root.left == null) ... 阅读全文
posted @ 2014-02-03 08:40 Averill Zheng 阅读(135) 评论(0) 推荐(1) 编辑
摘要: Given an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your maximu... 阅读全文
posted @ 2014-02-03 08:29 Averill Zheng 阅读(178) 评论(0) 推荐(0) 编辑
摘要: 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 @ 2014-02-03 02:44 Averill Zheng 阅读(314) 评论(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 @ 2014-02-03 02:17 Averill Zheng 阅读(151) 评论(0) 推荐(0) 编辑