摘要: 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 @ 2015-02-26 20:59 vincently 阅读(119) 评论(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 @ 2015-02-26 20:54 vincently 阅读(170) 评论(0) 推荐(0) 编辑
摘要: 1. 简要介绍 关于二叉树问题,由于其本身固有的递归属性,通常我们可以用递归算法来解决。(《编程之美》,P253) 总结的题目主要以leetcode题目、《剑指offer》以及《编程之美》的题目。2. 测试用例 普通二叉树(完全二叉树,不完全二叉树) 特殊二叉树(所有节点都没有右子节点的二... 阅读全文
posted @ 2015-02-26 19:44 vincently 阅读(828) 评论(0) 推荐(0) 编辑
摘要: Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.解法:自底向上 时间复杂度O(n), 空间复杂度O(logN) 1 clas... 阅读全文
posted @ 2015-02-26 19:16 vincently 阅读(199) 评论(0) 推荐(0) 编辑