题目描述:
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...
分类:
其他好文 时间:
2014-12-26 18:46:42
阅读次数:
178
题目
Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given sum.
For example:
Given the below binary tree and sum = 22,
5
/ ...
分类:
其他好文 时间:
2014-12-24 18:07:42
阅读次数:
136
题目:Given a binary tree containing digits from0-9only, each root-to-leaf path could represent a number.An example is the root-to-leaf path1->2->3which ...
分类:
其他好文 时间:
2014-12-24 17:39:33
阅读次数:
147
题目
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.
Find th...
分类:
其他好文 时间:
2014-12-23 15:35:28
阅读次数:
167
求对于给定一个连通图,加多少条边可以变成边双连通图。
一个有桥的连通图要变成边双连通图的话,把双连通子图收缩为一个点,形成一颗树。需要加的边为(leaf+1)/2 (leaf为叶子结点个数)。
对于此题,有重边但重边不加入计算。
重边的话,要么在开始去掉,要么用桥来计算入度。
因为桥不属于任何一个边双连通分支,其余的边和每个顶点都属于且只属于一个边双连通分支。对于重边而言,只有一对...
分类:
移动开发 时间:
2014-12-22 21:23:30
阅读次数:
215
一、UML图
二、概念
组合模式(Composite):将对象组合成树形结构以表示“部分-整体”的层次结构。组合模式使得用户对单个对象和组合对象的使用具有一致性。
三、说明
角色:
(1)Component:为组合中的对象声明接口,在适当情况下,实现所有类共有接口的默认行为。声明一个接口用于访问和管理Component 的子部件。
(2)Leaf:在组合中白哦是...
分类:
编程语言 时间:
2014-12-22 18:06:27
阅读次数:
263
题目
Given a binary tree, find its maximum depth.
The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.
解答
求二叉树的最大深度。
递归:a.若二叉树为空,...
分类:
其他好文 时间:
2014-12-20 15:38:37
阅读次数:
173
题目
Given a binary tree, return the bottom-up level order traversal of its nodes' values. (ie, from left to right, level by level from leaf to root).
For example:
Given binary tree {3,9,20,#,#...
分类:
其他好文 时间:
2014-12-19 17:30:36
阅读次数:
172
Path SumGiven 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 give...
分类:
其他好文 时间:
2014-12-18 22:11:57
阅读次数:
157
Sum Root to Leaf Numbers Given a binary tree containing digits from 0-9 only, each root-to-leaf path could represent a number.An example is the root-t...
分类:
其他好文 时间:
2014-12-18 22:11:40
阅读次数:
206