[LeetCode] 637. Average of Levels in Binary Tree
来源:互联网 发布:苹果手机官方软件 编辑:程序博客网 时间:2024/06/01 10:36
void aveLevHelp(vector<double> &res,vector<int> &cnt,unsigned int lev,TreeNode *r){if(r==NULL) return;if(lev+1>res.size()){res.push_back(0);cnt.push_back(0);}res[lev]+=r->val;cnt[lev]++;aveLevHelp(res,cnt,lev+1,r->left);aveLevHelp(res,cnt,lev+1,r->right);}vector<double> averageOfLevels(TreeNode* r){vector<double> res;vector<int> cnt;aveLevHelp(res,cnt,0,r);for(unsigned int i=0;i<res.size();++i){res[i]/=cnt[i];}return res;}
阅读全文
0 0
- [Leetcode] Binary tree-- 637. Average of Levels in Binary Tree
- LeetCode average Of Levels in Binary Tree
- Average of Levels in Binary Tree(leetcode)
- LeetCode 637. Average of Levels in Binary Tree
- [LeetCode]637. Average of Levels in Binary Tree
- leetcode 637. Average of Levels in Binary Tree
- [LeetCode]637. Average of Levels in Binary Tree
- 【LeetCode】637. Average of Levels in Binary Tree
- leetcode 637. Average of Levels in Binary Tree
- leetcode 637. Average of Levels in Binary Tree
- [LeetCode] 637. Average of Levels in Binary Tree
- leetcode 637. Average of Levels in Binary Tree
- <leetcode>637. Average of Levels in Binary Tree
- LeetCode 637. Average of Levels in Binary Tree
- [LeetCode] 637.Average of Levels in Binary Tree
- 637. Average of Levels in Binary Tree
- 637. Average of Levels in Binary Tree
- 637. Average of Levels in Binary Tree
- mysql 下载 mysql jdbc jar 下载 ,mysql-5.7.17 解压版安装
- ReactNative源码篇:渲染原理
- cocos2d-js PageView用法
- hdu4135(容斥入门题)
- Git_基础
- [LeetCode] 637. Average of Levels in Binary Tree
- MySQL 加锁处理分析
- css em
- xml头报错
- VUE.JS
- Ubuntu16.04下Mongodb安装部署步骤(图文详解)
- Android样式的开发:drawable汇总篇
- 魔术师发牌问题 C语言
- 炸弹人2