码迷,mamicode.com
首页 >  
搜索关键字:binary trees    ( 12390个结果)
34: Maximum Depth of Binary Tree
/************************************************************************/ /* 34: Maximum Depth of Binary Tree */ /*********************************.....
分类:其他好文   时间:2015-01-27 23:07:10    阅读次数:210
Binary Tree Maximum Path Sum
Given a binary tree, find the maximum path sum. The path may start and end at any node in the tree. 求树的一点到另一点的最大路径,利用递归的方法,ans 在 左子树,右子树,root+左+右的最大中产生。 /** * Definition for binary tree * struct ...
分类:其他好文   时间:2015-01-27 22:01:36    阅读次数:112
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. Calling next() will return the next smallest number in the BST. Note: next() and...
分类:其他好文   时间:2015-01-27 21:58:04    阅读次数:172
Balanced Binary Tree
检测一个树是否平衡,不需要求出高度,而是从底到顶检测是否平衡,这样才算法时间复杂度为O(n)。但是需要额外的O(logn)的空间 /** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(...
分类:其他好文   时间:2015-01-27 21:55:39    阅读次数:164
function [ binary,decimal ] = num2binary16( number )
function [ binary,decimal ] = num2binary16( number ) %The IEEE 754 standard specifies a binary16 as having the following format: %Sign bit: 1 bit %Exp...
分类:其他好文   时间:2015-01-27 20:12:35    阅读次数:179
leetcode------Add Binary
标题:Add Binary通过率:25.1%难度:简单Given two binary strings, return their sum (also a binary string).For example,a ="11"b ="1"Return"100".本题主要就是模拟二进制去处理,跟上次做到...
分类:其他好文   时间:2015-01-27 19:57:32    阅读次数:107
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 never diffe...
分类:其他好文   时间:2015-01-27 18:29:32    阅读次数:168
[LeetCode]Scramble String
Given a string s1, we may represent it as a binary tree by partitioning it to two non-empty substrings recursively. Below is one possible representation of s1 = "great": great / gr ...
分类:其他好文   时间:2015-01-27 16:25:51    阅读次数:169
[LeetCode]Maximal Rectangle
Given a 2D binary matrix filled with 0's and 1's, find the largest rectangle containing all ones and return its area. 动态规划 用left[ ]数组纪录该点距离最左边(在矩形内部)的1的距离,用right[ ]数组纪录该点距离最右边(在矩形内部)的1距离,height[ ]...
分类:其他好文   时间:2015-01-27 09:32:51    阅读次数:131
[LeetCode] Binary Tree Upside Down的三种解法
Given a binary tree where all the right nodes are either leaf nodes with a sibling (a left node that shares the same parent node) or empty, flip it upside down and turn it into a tree where the origin...
分类:其他好文   时间:2015-01-27 07:07:43    阅读次数:193
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!