题意:已知无向图,问添加最少的边使之成为边双连通图
思路:显然先缩点成一棵树,添加最少边使一棵树的边双连通
此处有结论:对于一棵树添加(1+leaf)>>1 条无向边就能构造成一个双连通图,构造方法显然(脑补一下
//216K 63MS C++ 1754B
#include
#include
#include
#include
...
分类:
其他好文 时间:
2015-04-24 09:09:05
阅读次数:
118
problem:
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...
分类:
其他好文 时间:
2015-04-23 11:02:24
阅读次数:
163
先看看组合模式的定义吧:“将对象组合成树形结构以表示‘部分-整体’的层次结构。组合模式使得用户对单个对象和组合对象的使用具有一致性。”
/**
* 抽象组件
*/
public interface Component {
void operation();
}
/**
* 叶子组件
*/
interface Leaf extends Component{
}
/**
* 容器...
分类:
编程语言 时间:
2015-04-22 18:09:40
阅读次数:
140
题目来自于leetcode
https://leetcode.com/problems/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 ...
分类:
其他好文 时间:
2015-04-21 18:05:43
阅读次数:
156
problem:
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.
Hide Tags
Tr...
分类:
其他好文 时间:
2015-04-21 11:20:10
阅读次数:
108
1 public class Leaf { 2 3 int i = 0; 4 5 Leaf inceament() { 6 i++; 7 return this; 8 } 9 10 void print() {11 ...
分类:
编程语言 时间:
2015-04-19 01:11:18
阅读次数:
213
题目描述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
题目链接:Binary Tree Level Order Traversal
II
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 exam...
分类:
其他好文 时间:
2015-04-17 18:16:21
阅读次数:
176
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.Fo...
分类:
其他好文 时间:
2015-04-17 08:21:12
阅读次数:
101
题目链接:Maximum Depth of Binary Tree
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.
这道题...
分类:
其他好文 时间:
2015-04-16 10:25:57
阅读次数:
123