摘要: Given an array where elements are sorted in ascending order, convert it to a height balanced BST.二分递归转换Hide TagsTreeDepth-first Search/** * Definition... 阅读全文
posted @ 2014-11-20 13:04 li303491 阅读(104) 评论(0) 推荐(0) 编辑
摘要: Given a binary tree, determine if it is height-balanced.For this problem, a height-balanced binary tree is defined as a binary tree in which the depth... 阅读全文
posted @ 2014-11-20 00:44 li303491 阅读(129) 评论(0) 推荐(0) 编辑
摘要: 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 le... 阅读全文
posted @ 2014-11-19 23:01 li303491 阅读(133) 评论(0) 推荐(0) 编辑
摘要: Given a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node down to the farthest le... 阅读全文
posted @ 2014-11-19 22:07 li303491 阅读(104) 评论(0) 推荐(0) 编辑
摘要: 引例:迷宫问题首先我们来想象一只老鼠,在一座不见天日的迷宫内,老鼠在入口处进去,要从出口出来。那老鼠会怎么走?当然可以是这样的:老鼠如果遇到直路,就一直往前走,如果遇到分叉路口,就任意选择其中的一条继续往下走,如果遇到死胡同,就退回到最近的一个分叉路口,选择另一条道路再走下去,如果遇到了出口,老鼠的... 阅读全文
posted @ 2014-11-19 19:27 li303491 阅读(3876) 评论(0) 推荐(2) 编辑
摘要: Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum.Fo... 阅读全文
posted @ 2014-11-19 19:14 li303491 阅读(136) 评论(0) 推荐(0) 编辑
摘要: Given two binary trees, write a function to check if they are equal or not.Two binary trees are considered equal if they are structurally identical an... 阅读全文
posted @ 2014-11-19 18:21 li303491 阅读(101) 评论(0) 推荐(0) 编辑
摘要: Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).For example, this binary tree is symmetric: 1 / \ ... 阅读全文
posted @ 2014-11-19 18:10 li303491 阅读(117) 评论(0) 推荐(0) 编辑
摘要: Given a stringsconsists of upper/lower-case alphabets and empty space characters' ', return the length of last word in the string.If the last word doe... 阅读全文
posted @ 2014-11-18 20:30 li303491 阅读(163) 评论(0) 推荐(0) 编辑
摘要: Given two binary strings, return their sum (also a binary string).For example,a ="11"b ="1"Return"100".Hide TagsMathStringclass Solution {public: s... 阅读全文
posted @ 2014-11-18 19:53 li303491 阅读(119) 评论(0) 推荐(0) 编辑