码迷,mamicode.com
首页 >  
搜索关键字:binary trees    ( 12390个结果)
LeetCode (12) 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 tree and sum...
分类:其他好文   时间:2015-04-18 22:01:55    阅读次数:136
二分查找法
$arr = array(4,58,11,34,88,45,32,54,63,78);function binary($arr,$bnum){if(is_array($arr) && count($arr) > 0){sort($arr);$start = 0;$end = count($arr)-...
分类:其他好文   时间:2015-04-18 21:50:07    阅读次数:105
google code jam Round 1A 2015 Problem C. Logging
Problem A certain forest consists of N trees, each of which is inhabited by a squirrel. The boundary of the forest is the convex polygon of smallest area which contains every tree, as if a giant r...
分类:其他好文   时间:2015-04-18 19:14:41    阅读次数:169
04-树5 Complete Binary Search Tree
这题也是第二次做,本想第一次做时参考的算法会和老师讲的一样,不想老师讲的算法用在这题感觉还不如思雪园友的算法(http://www.cnblogs.com/sixue/archive/2015/04.html)来的简单,不过老师给的思路是一种挺通用的思路,可以用来解决一系列的问题,但我目前看着有点吃...
分类:其他好文   时间:2015-04-18 12:54:00    阅读次数:187
if else 和 switch的效率
switch在判断分支时,没有判断所有的可能性,而是用一个静态表来解决这个问题,所以速度要比if-else快。但是,switch对较复杂的表达式进行判断,所以当我们需要判断一些简单数值时,用switch较好。下面是转载的内容,我看说的很有道理switch和if-else相比,由于使用了Binary ...
分类:其他好文   时间:2015-04-18 11:28:11    阅读次数:105
Add Binary
Given two binary strings, return their sum (also a binary string).For example,a ="11"b ="1"Return"100".Analyse: Using XOR(^) to compute the result of ...
分类:其他好文   时间:2015-04-18 11:25:04    阅读次数:105
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-04-18 07:35:36    阅读次数:135
145. Binary Tree Postorder Traversal
Given a binary tree, return thepostordertraversal of its nodes' values.For example:Given binary tree{1,#,2,3}, 1 \ 2 / 3return[3,2,1].No...
分类:其他好文   时间:2015-04-18 07:33:53    阅读次数:118
144. Binary Tree Preorder Traversal
Given a binary tree, return thepreordertraversal of its nodes' values.For example:Given binary tree{1,#,2,3}, 1 \ 2 / 3return[1,2,3].先pu...
分类:其他好文   时间:2015-04-18 07:32:59    阅读次数:123
Construct Binary Tree from Inorder and Postorder Traversal
跟另一道题一样,不多说了public class Solution { public TreeNode buildTree(int[] inorder, int[] postorder) { // post就是pre的近似倒过来 if(inorder==null||...
分类:其他好文   时间:2015-04-18 06:26:50    阅读次数:175
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!