码迷,mamicode.com
首页 >  
搜索关键字:binary trees    ( 12390个结果)
leetcode--Add binary
题目描述: Add Binary Given two binary strings, return their sum (also a binary string). For example, a = "11" b = "1" Return "100". 解题思路: 求两个二进制组成的数字的和。首先有几种特殊的情况,a、b均为空,a为空、b非空,a非空、b为空;我们...
分类:其他好文   时间:2015-05-04 18:13:48    阅读次数:154
Recover Binary Search Tree -- leetcode
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 straight forward. Could you devis...
分类:其他好文   时间:2015-05-04 18:06:38    阅读次数:119
hdu 1131 Count the Trees
卡特兰数*阶乘就是答案 第一次用java。。高精度写起来好快。。。。不过代码比较丑。。import java.math.BigInteger;import java.util.Scanner; public class Main{ public static void main(St...
分类:其他好文   时间:2015-05-04 17:37:39    阅读次数:149
[LeetCode] Path Sum
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 bina...
分类:其他好文   时间:2015-05-04 15:30:49    阅读次数:113
公共祖先--binary tree
找binary tree中两个node第一个公共祖先。注意不一定是BST想法:p,q都在左子树,就branch left。如果都在right,就branch right。如果不在same side,就返回first common ancestor所以主要是在left subtree和right su...
分类:其他好文   时间:2015-05-04 13:31:09    阅读次数:155
【leetcode】Binary Search Tree Iterator(middle)
Implement an iterator over a binary search tree (BST). Your iterator will be initialized with the root node of a BST.Callingnext()will return the next...
分类:其他好文   时间:2015-05-04 13:27:57    阅读次数:115
leetcode-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 n...
分类:其他好文   时间:2015-05-04 12:06:20    阅读次数:96
13 Red-black Trees
13 Red-black Trees Red-black trees are one of many search-tree schemes that are "balanced" in order to guarantee that basic dynamic-set operations tak...
分类:其他好文   时间:2015-05-04 11:46:23    阅读次数:187
Validate Binary Search Tree -- leetcode
Given a binary tree, determine if it is a valid binary search tree (BST). Assume a BST is defined as follows: The left subtree of a node contains only nodes with keys less than the node's key.Th...
分类:其他好文   时间:2015-05-04 10:12:08    阅读次数:100
【LeetCode】Binary Tree Postorder Traversal
Given a binary tree, return the postorder traversal of its nodes' values....
分类:其他好文   时间:2015-05-03 20:42:49    阅读次数:96
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!