码迷,mamicode.com
首页 >  
搜索关键字:binary trees    ( 12390个结果)
leetcode[94]Binary Tree Inorder Traversal
Given a binary tree, return theinordertraversal of its nodes' values.For example:Given binary tree{1,#,2,3}, 1 \ 2 / 3return[1,3,2].Note...
分类:其他好文   时间:2015-02-09 14:05:14    阅读次数:107
leetcode[100]Same Tree
Given two binary trees, write a function to check if they are equal or not.Two binary trees are considered equal if they are structurally identical an...
分类:其他好文   时间:2015-02-09 14:04:39    阅读次数:117
leetcode[99]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 ...
分类:其他好文   时间:2015-02-09 14:04:10    阅读次数:148
leetcode[95]Unique Binary Search Trees II
Givenn, generate all structurally uniqueBST's(binary search trees) that store values 1...n.For example,Givenn= 3, your program should return all 5 uni...
分类:其他好文   时间:2015-02-09 14:03:20    阅读次数:85
leetcode[96]Unique Binary Search Trees
Givenn, how many structurally uniqueBST's(binary search trees) that store values 1...n?For example,Givenn= 3, there are a total of 5 unique BST's. 1.....
分类:其他好文   时间:2015-02-09 14:02:41    阅读次数:123
leetcode[98]Validate Binary Search Tree
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 n...
分类:其他好文   时间:2015-02-09 14:01:23    阅读次数:110
Leetcode_Minimum Depth of Binary Tree
题意为得出二叉树的最小深度,但深度是定义为从根节点到叶子节点的最少节点数。 容易出错的地方:为空节点时,直接返回0。这是不对的,要判断其是否有兄弟节点,没有兄弟节点的时候才能返回0,即这个节点的父节点是一个叶子节点。 错解1: class Solution { public: int minDepth(TreeNode *root) { if(root==nullptr) ...
分类:其他好文   时间:2015-02-09 12:58:55    阅读次数:132
leetcode[173]Binary Search Tree Iterator
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-02-09 00:45:05    阅读次数:159
leetcode_81_Search in Rotated Sorted Array II
欢迎转载,如有错误或疑问请留言纠正,谢谢 Search in Rotated Sorted Array II  Follow up for "Search in Rotated Sorted Array": What if duplicates are allowed? Would this affect the run-time complexity? How and w...
分类:其他好文   时间:2015-02-08 18:16:36    阅读次数:199
leetcode_69_Sqrt(x)
欢迎转载,如有错误或疑问请留言纠正,谢谢 Sqrt(x) Implement int sqrt(int x). Compute and return the square root of x. //vs2012测试代码 //using binary search to solve sqrt(x) //alternative method: newton me...
分类:其他好文   时间:2015-02-08 16:55:02    阅读次数:171
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!