摘要: Validate Binary Search TreeAug 31 '12Given a binary tree, determine if it is a valid binary search tree (BST).Assume a BST is defined as follows:The left subtree of a node contains only nodes with keysless thanthe node's key.The right subtree of a node contains only nodes with keysgreater th 阅读全文
posted @ 2013-03-01 14:13 西施豆腐渣 阅读(128) 评论(0) 推荐(0) 编辑
摘要: Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below.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(i.e.,2+3+5+1= 11).Note:Bonus point if you... 阅读全文
posted @ 2013-03-01 07:23 西施豆腐渣 阅读(248) 评论(0) 推荐(0) 编辑
摘要: Trapping Rain WaterMar 10 '12Givennnon-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining.For example,Given[0,1,0,2,1,0,1,3,2,1,2,1], return6.The above elevation map is represented by array [0,1,0,2,1,0,1,3,2, 阅读全文
posted @ 2013-03-01 06:20 西施豆腐渣 阅读(181) 评论(0) 推荐(0) 编辑
摘要: Write a program to solve a Sudoku puzzle by filling the empty cells.Empty cells are indicated by the character'.'.You may assume that there will be only one unique solution.A sudoku puzzle......and its solution numbers marked in red.uncompleted.public class Solution { ArrayList<HashSet< 阅读全文
posted @ 2013-03-01 00:59 西施豆腐渣 阅读(140) 评论(0) 推荐(0) 编辑