摘要:
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... 阅读全文
摘要:
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... 阅读全文
摘要:
1. 简要介绍 关于二叉树问题,由于其本身固有的递归属性,通常我们可以用递归算法来解决。(《编程之美》,P253) 总结的题目主要以leetcode题目、《剑指offer》以及《编程之美》的题目。2. 测试用例 普通二叉树(完全二叉树,不完全二叉树) 特殊二叉树(所有节点都没有右子节点的二... 阅读全文
摘要:
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... 阅读全文