上一页 1 ··· 6 7 8 9 10 11 12 下一页
摘要: 原题地址:https://oj.leetcode.com/problems/binary-tree-maximum-path-sum/题意:Given a binary tree, find the maximum path sum.The path may start and end at any... 阅读全文
posted @ 2014-05-22 14:43 南郭子綦 阅读(3725) 评论(0) 推荐(0) 编辑
摘要: 原题地址:https://oj.leetcode.com/problems/populating-next-right-pointers-in-each-node-ii/题意:Follow up for problem "Populating Next Right Pointers in Each ... 阅读全文
posted @ 2014-05-22 12:20 南郭子綦 阅读(1891) 评论(0) 推荐(0) 编辑
摘要: 原题地址:https://oj.leetcode.com/problems/populating-next-right-pointers-in-each-node/题意: 1 / \ 2 3 / \ / \ 4 5 6 7变为: ... 阅读全文
posted @ 2014-05-22 10:52 南郭子綦 阅读(2050) 评论(0) 推荐(0) 编辑
摘要: 原题地址:https://oj.leetcode.com/problems/copy-list-with-random-pointer/题意:A linked list is given such that each node contains an additional random pointe... 阅读全文
posted @ 2014-05-22 10:37 南郭子綦 阅读(7663) 评论(1) 推荐(0) 编辑
摘要: 原题地址:http://oj.leetcode.com/problems/convert-sorted-list-to-binary-search-tree/题意:将一条排序好的链表转换为二叉查找树,二叉查找树需要平衡。解题思路:两个思路:一,可以使用快慢指针来找到中间的那个节点,然后将这个节点作为... 阅读全文
posted @ 2014-05-11 19:18 南郭子綦 阅读(3984) 评论(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 南郭子綦 阅读(2743) 评论(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 南郭子綦 阅读(3649) 评论(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 南郭子綦 阅读(2649) 评论(0) 推荐(0) 编辑
摘要: 原题地址:http://oj.leetcode.com/problems/binary-tree-level-order-traversal/题意:二叉树的层序遍历的实现。解题思路:二叉树的层序遍历可以用bfs或者dfs来实现。这里使用的dfs实现,代码比较简洁。实际上,二叉树的先序遍历就是dfs实... 阅读全文
posted @ 2014-05-11 17:55 南郭子綦 阅读(5011) 评论(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 南郭子綦 阅读(2169) 评论(0) 推荐(0) 编辑
摘要: 原题地址:http://oj.leetcode.com/problems/flatten-binary-tree-to-linked-list/题意:Given a binary tree, flatten it to a linked list in-place.For example,Given... 阅读全文
posted @ 2014-05-10 22:55 南郭子綦 阅读(3779) 评论(0) 推荐(0) 编辑
摘要: 原题地址:http://oj.leetcode.com/problems/binary-tree-postorder-traversal/题意:实现后序遍历。递归实现比较简单,非递归实现。解题思路:这道题的迭代求解比先序遍历和后序遍历要麻烦一些。假设一棵树是这样的: ... 阅读全文
posted @ 2014-05-10 18:40 南郭子綦 阅读(3269) 评论(0) 推荐(0) 编辑
摘要: 原题地址:http://oj.leetcode.com/problems/binary-tree-preorder-traversal/题意:这题用递归比较简单。应该考察的是使用非递归实现二叉树的先序遍历。先序遍历的遍历顺序是:根,左子树,右子树。解题思路:如果树为下图: ... 阅读全文
posted @ 2014-05-10 12:44 南郭子綦 阅读(4203) 评论(0) 推荐(0) 编辑
摘要: 原题地址:http://oj.leetcode.com/problems/binary-tree-inorder-traversal/题意:二叉树的中序遍历。这道题用递归比较简单,考察的是非递归实现二叉树中序遍历。中序遍历顺序为:左子树,根,右子树。如此递归下去。解题思路:假设树为: ... 阅读全文
posted @ 2014-05-10 11:50 南郭子綦 阅读(4857) 评论(0) 推荐(0) 编辑
上一页 1 ··· 6 7 8 9 10 11 12 下一页