BST——最短路径
2016-06-13 09:01
302 查看
算法:DFS:
static int sum = 0;
static int max =100;
static int i=0;
public static void pathSum(TreeNode t){
sum += t.value;
if(t.left == null&&t.right == null){
if(max > sum)
max = sum;
sum -= t.value;
return;
}
if(t.left != null)
pathSum(t.left);
if(t.right != null)
pathSum(t.right);
sum=sum - t.value;
}
static int sum = 0;
static int max =100;
static int i=0;
public static void pathSum(TreeNode t){
sum += t.value;
if(t.left == null&&t.right == null){
if(max > sum)
max = sum;
sum -= t.value;
return;
}
if(t.left != null)
pathSum(t.left);
if(t.right != null)
pathSum(t.right);
sum=sum - t.value;
}
相关文章推荐
- Win2003利用dfs(分布式文件系统)在负载均衡下的文件同步配置方案
- win2003分布式文件系统(dfs)配置方法[图文详解]
- win2003分布式文件系统及其部署 图文教程
- Hadoop2.6+jdk8的安装部署(1)——使用jar包安装部署【详细】
- Hadoop FS Shell
- DFS使用方法总结
- FastDFS注意事项
- 无忧技术带您预览DFS(分布式文件系统)管理控制台
- C 语言实现迷宫 DFS算法
- 一幅图弄清DFT与DTFT,DFS的关系
- HDFS---Namenode
- HDFS ---- Services startup
- POJ1523 SPF dfs
- poj1731 Orders dfs
- Surrounded Regions
- Binary Tree Zigzag Level Order Traversal,Restore IP Addresses,Word Search,Simplify Path
- DFS基础(1)
- HDU1241 Oil Deposits
- DFS算法有趣小题目
- HDU 1016 Prime Ring Problem