leetcode814
class Solution {
public:
TreeNode* pruneTree(TreeNode* root) {
if(root==NULL)
{
return nullptr;
}
if(root->left!=NULL)
{
root->left = pruneTree(root->left);
}
if(root->right!=NULL)
{
root->right = pruneTree(root->right);
}
if(root->left==NULL&&root->right==NULL&&root->val==)
{
return NULL;
}
return root;
}
};
leetcode814的更多相关文章
- [Swift]LeetCode814. 二叉树剪枝 | Binary Tree Pruning
We are given the head node root of a binary tree, where additionally every node's value is either a ...
- leetcode814 Binary Tree Pruning
""" We are given the head node root of a binary tree, where additionally every node's ...
随机推荐
- Rails 5 Test Prescriptions 第6章Adding Data to Tests
bcreate the data quickly and easily.考虑测试运行的速度. fixtures and factories.以及下章讨论的test doubles,还有原生的creat ...
- Android 之低版本高版本实现沉浸式状态栏
沉浸式状态栏确切的说应该叫做透明状态栏.一般情况下,状态栏的底色都为黑色,而沉浸式状态栏则是把状态栏设置为透明或者半透明. 沉浸式状态栏是从android Kitkat(Android 4.4)开始出 ...
- 机器学习算法--svm实战
1.不平衡数据分类问题 对于非平衡级分类超平面,使用不平衡SVC找出最优分类超平面,基本的思想是,我们先找到一个普通的分类超平面,自动进行校正,求出最优的分类超平面 测试代码如下: import nu ...
- vs警告 当前源代码跟内置的版本不一致解决办法
本文转载于:http://blog.csdn.net/bull521/article/details/51334464 vs警告 当前源代码跟内置的版本不一致解决办法 1.删除掉 我的文档/visua ...
- [转载]c语言指针segmentation fault 指针常常错误的小地方
http://www.cnblogs.com/qingjoin/archive/2012/03/20/2408944.html #include <stdio.h> ] = ] = ] = ...
- 终于知道为什么我的mysql总是卸载的不干净以及老是找不到my.ini文件
感谢博主: http://blog.sina.com.cn/s/blog_6fc5bfa90100qmr9.html 如果你的电脑里装过MySQL,想再重新安装MySQL的时候可能就会因为前一版本卸载 ...
- PHP获取访客IP、地区位置信息、浏览器、来源页面
不多说了,每个方法都注释了,可以直接用: <?php //这个类似用来获取访客信息的 //方便统计 class visitorInfo { //获取访客ip public function ge ...
- 免费180天的Ashampoo Anti-Virus 2014
官方网站:https://www.ashampoo.com/cn/rmb/pde/0449/Security_Software/Ashampoo-Anti-Virus 活动页面:http://www. ...
- Android sdk 更新后编译不过,【Could not find com.android.sdklib.build.ApkBuilderMain】
最近更新了Android sdk,发现编译不过了 解决方案: 进入 sdk/tool/lib/ 目录下,看看有没有 sdklib.jar 这个文件,如果没有看看有没有sdklib-25.*.*.jar ...
- Visual C#中的winform/webform/asp.net控件命名规范
1.控件命名规范 类型 前缀 示例 AdRotator ...