树
0_o_c
这个作者很懒,什么都没留下…
展开
-
path-sum
1、链接:path-sum 来源:牛客网热度指数:5068时间限制:1秒空间限制:32768K 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. For原创 2017-10-21 01:07:10 · 172 阅读 · 0 评论 -
construct-binary-tree-from-preorder-and-inorder-traversal
1、来源:construct-binary-tree-from-preorder-and-inorder-traversal Given preorder and inorder traversal of a tree, construct the binary tree. Note: You may assume that duplicates do not exist in the tr原创 2017-10-22 09:56:58 · 269 阅读 · 0 评论 -
construct-binary-tree-from-inorder-and-postorder-traversal
1、链接:这里写链接内容来源:牛客网Given inorder and postorder traversal of a tree, construct the binary tree. Note: You may assume that duplicates do not exist in the tree.2、思路,通过中序和后序来构建树: 前序的第一个元素为当前根结点root; 在后序中原创 2017-10-22 09:45:14 · 326 阅读 · 0 评论 -
convert-sorted-array-to-binary-search-tree
1、来源:convert-sorted-array-to-binary-search-tree 牛客网Given an array where elements are sorted in ascending order, convert it to a height balanced BST.2、思路: 二分查找,注意如果数组的length为偶数,则作为根结点的是右边的元素; 当前根结点的左右子结原创 2017-10-22 08:57:04 · 206 阅读 · 0 评论 -
convert-sorted-list-to-binary-search-tree
1、链接:convert-sorted-list-to-binary-search-tree 来源:牛客网Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.2、思路:通过快慢指针找到中间结点,将中间结点设置为空(注意设置该结点为空,需原创 2017-10-21 01:32:57 · 228 阅读 · 0 评论 -
balanced-binary-tree
1、链接:balanced-binary-tree来源:牛客网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 of the two subtre原创 2017-10-21 01:20:18 · 230 阅读 · 0 评论 -
path-sum-ii
1、链接:path-sum-ii 来源:牛客网 Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given sum. For example: Given the below binary tree andsum = 22, 5原创 2017-10-21 01:17:48 · 233 阅读 · 0 评论 -
minimum-depth-of-binary-tree
1、链接:minimum-depth-of-binary-tree 来源:牛客网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 leaf node.2、思原创 2017-10-20 22:08:39 · 211 阅读 · 0 评论 -
sum-root-to-leaf-numbers
1、题目:sum-root-to-leaf-numbers 来源:牛客网 Given a binary tree containing digits from0-9only, each root-to-leaf path could represent a number. An example is the root-to-leaf path1->2->3which represents the n原创 2017-10-20 22:26:07 · 223 阅读 · 0 评论 -
populating-next-right-pointers-in-each-node-ii
1、populating-next-right-pointers-in-each-node-ii 来源:牛客网Follow up for problem "Populating Next Right Pointers in Each Node". What if the given tree could be any binary tree? Would your previous solution原创 2017-10-20 23:17:26 · 269 阅读 · 0 评论 -
binary-tree-zigzag-level-order-traversal
1、来源:binary-tree-zigzag-level-order-traversal牛客网Given a binary tree, return the zigzag level order traversal of its nodes' values. (ie, from left to right, then right to left for the next level and alt原创 2017-10-24 00:06:22 · 303 阅读 · 0 评论