码迷,mamicode.com
首页 >  
搜索关键字:binary tree paths    ( 24317个结果
HDU 1166 敌兵布阵 Segment Tree题解
本题是最基本的分段树操作了。或者一般叫线段树,不过好像和线段没什么关系,只是分段了。 不使用lazy标志,更新只是更新单点。 如果不使用分段树,那么更新时间效率只需要O(1),使用分段树更新效率就需要O(lgn)了。 但是不是用分段树,那么查询的时间效率是O(n),而分段树查询效率是O(lgn) 这就是amortize分摊了时间,而且lgn真的很快,数据不是非常巨大的时候,接近常数了。 故...
分类:其他好文   时间:2014-06-20 12:41:05    阅读次数:206
抽象语法树(Abstract Syntax Tree)
抽象语法树(Abstract Syntax Tree)   抽象语法树(AST)表示组成程序的结构,可以让程序员更容易使用,F# 适宜这种开发的一个原因就是它的联合类型。这种类型非常适合表示语言,因为它可以用来表示相关而结构不相同的项目。下面就是抽象语法树的例子:   type Ast =     | Ident of string     | Val of System.Double...
分类:其他好文   时间:2014-06-20 11:33:28    阅读次数:200
LeetCode: Path Sum II [113]
【题目】 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 and sum = 22, 5 / 4 8 / / 11 13 4 ...
分类:其他好文   时间:2014-06-20 10:53:08    阅读次数:181
leetcode -day27 Recover Binary Search Tree & Interleaving String
1、 ?? Recover Binary Search Tree Two elements of a binary search tree (BST) are swapped by mistake. Recover the tree without changing its structure. Note: A solution using O(n) space is pretty...
分类:其他好文   时间:2014-06-20 10:13:49    阅读次数:243
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 subtrees of every node...
分类:其他好文   时间:2014-06-20 09:02:56    阅读次数:232
Path Sum
题目 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 example: Given the below binary t...
分类:其他好文   时间:2014-06-07 15:31:32    阅读次数:179
LeetCode: Populating Next Right Pointers in Each Node [116]
【题目】 Given a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *next; } Populate each next pointer to point to its next right node. If there is no next right node, the next pointer should be...
分类:其他好文   时间:2014-06-07 14:28:36    阅读次数:215
LeetCode: Path Sum [112]
【题目】 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 example: Given the below binary tree and sum = 22, 5 / ...
分类:其他好文   时间:2014-06-07 13:57:37    阅读次数:210
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 and sum = 22, 5 ...
分类:其他好文   时间:2014-06-07 13:47:22    阅读次数:191
LeetCode: Flatten Binary Tree to Linked List [114]
【题目】 Given a binary tree, flatten it to a linked list in-place. For example, Given 1 / 2 5 / \ 3 4 6 The flattened tree should look like: 1 2 3 4 \...
分类:其他好文   时间:2014-06-07 11:37:00    阅读次数:153
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!