摘要: 原题地址:http://oj.leetcode.com/problems/convert-sorted-list-to-binary-search-tree/题意:将一条排序好的链表转换为二叉查找树,二叉查找树需要平衡。解题思路:两个思路:一,可以使用快慢指针来找到中间的那个节点,然后将这个节点作为... 阅读全文
posted @ 2014-05-11 19:18 南郭子綦 阅读(3985) 评论(1) 推荐(0) 编辑
摘要: 原题地址:http://oj.leetcode.com/problems/convert-sorted-array-to-binary-search-tree/题意:将一个排序好的数组转换为一颗二叉查找树,这颗二叉查找树要求是平衡的。解题思路:由于要求二叉查找树是平衡的。所以我们可以选在数组的中间那... 阅读全文
posted @ 2014-05-11 19:09 南郭子綦 阅读(3026) 评论(0) 推荐(0) 编辑
摘要: 原题地址:http://oj.leetcode.com/problems/binary-tree-level-order-traversal-ii/题意:Given a binary tree, return thebottom-up level ordertraversal of its node... 阅读全文
posted @ 2014-05-11 18:44 南郭子綦 阅读(2744) 评论(0) 推荐(0) 编辑
摘要: 原题地址:http://oj.leetcode.com/problems/minimum-depth-of-binary-tree/题意:Given a binary tree, find its minimum depth.The minimum depth is the number of no... 阅读全文
posted @ 2014-05-11 18:23 南郭子綦 阅读(3651) 评论(0) 推荐(0) 编辑
摘要: 原题地址:http://oj.leetcode.com/problems/binary-tree-zigzag-level-order-traversal/题意:Given a binary tree, return thezigzag level ordertraversal of its nod... 阅读全文
posted @ 2014-05-11 18:05 南郭子綦 阅读(2650) 评论(0) 推荐(0) 编辑
摘要: 原题地址:http://oj.leetcode.com/problems/binary-tree-level-order-traversal/题意:二叉树的层序遍历的实现。解题思路:二叉树的层序遍历可以用bfs或者dfs来实现。这里使用的dfs实现,代码比较简洁。实际上,二叉树的先序遍历就是dfs实... 阅读全文
posted @ 2014-05-11 17:55 南郭子綦 阅读(5012) 评论(0) 推荐(0) 编辑
摘要: 原题地址:http://oj.leetcode.com/problems/sum-root-to-leaf-numbers/题意:Given a binary tree containing digits from0-9only, each root-to-leaf path could repre... 阅读全文
posted @ 2014-05-11 10:07 南郭子綦 阅读(2170) 评论(0) 推荐(0) 编辑