码迷,mamicode.com
首页 >  
搜索关键字:binary    ( 11734个结果)
[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...
分类:其他好文   时间:2015-04-09 19:18:18    阅读次数:119
【LeetCode】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.思路基本的深搜,注意一点就是必须是根到叶子节点求和,不可在非叶子节点处停。代码/** * Definition for binary tree * struct TreeNode { *...
分类:其他好文   时间:2015-04-09 17:25:31    阅读次数:147
[LeetCode] Convert Sorted Array to Binary Search Tree
Given an array where elements are sorted in ascending order, convert it to a height balanced BST.Hide TagsTreeDepth-first Search方法一:递归,也是dfs/** * Defi...
分类:其他好文   时间:2015-04-09 17:08:07    阅读次数:105
[Leetcode] 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.Hide TagsDepth-first SearchLinked List方法一...
分类:其他好文   时间:2015-04-09 16:50:31    阅读次数:144
Balanced Binary Tree
判断一棵二叉树是否是平衡树 看到二叉树的题目,基本都可以用递归的思想求解。对于判断是否是一棵平衡树可分为以下几个步骤: 计算左子树和右子树的高度差是否大于1,是则返回false 判断左子树是否是平衡树,判断右子树是否是平衡树 class Solution {public: bool isBalanc...
分类:其他好文   时间:2015-04-09 15:18:20    阅读次数:100
Leetcode: Convert Sorted Array to Binary Search Tree
题目: Given an array where elements are sorted in ascending order, convert it to a height balanced BST.分析: 将已经排序好的数组转成高度平衡的二叉排序树。 依旧二分法。C++参考代码:/** * Definition for binary tree * struct TreeNode {...
分类:其他好文   时间:2015-04-09 13:51:49    阅读次数:112
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-04-09 13:33:52    阅读次数:106
LeetCode --- 94. Binary Tree Inorder Traversal
题目链接:Binary Tree Inorder Traversal Given a binary tree, return the inorder traversal of its nodes' values. For example: Given binary tree {1,#,2,3}, 1 \ 2 / 3 return ...
分类:其他好文   时间:2015-04-09 12:00:06    阅读次数:223
LeetCode --- 95. Unique Binary Search Trees II
题目链接:Unique Binary Search Trees II Given n, generate all structurally unique BST's (binary search trees) that store values 1...n. For example, Given n = 3, your program should return all 5 unique B...
分类:其他好文   时间:2015-04-09 11:59:05    阅读次数:171
Sum Root to Leaf Numbers--LeetCode
题目: Given a binary tree containing digits from 0-9 only, each root-to-leaf path could represent a number. An example is the root-to-leaf path 1->2->3 which represents the number 123. Fi...
分类:其他好文   时间:2015-04-09 11:51:56    阅读次数:161
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!