public class Solution
{
List<int> list = new List<int>(); private void postTree(TreeNode root)
{
if (root != null)
{
list.Add(root.val);
if (root.left != null)
{
postTree(root.left);
}
if (root.right != null)
{
postTree(root.right);
}
}
} public bool IsUnivalTree(TreeNode root)
{
postTree(root);
var count = list.GroupBy(x => x).Count();
if (count == )
{
return true;
}
return false;
}
}

leetcode965的更多相关文章

  1. [Swift]LeetCode965. 单值二叉树 | Univalued Binary Tree

    A binary tree is univalued if every node in the tree has the same value. Return true if and only if ...

  2. Leetcode965. Univalued Binary Tree单值二叉树

    如果二叉树每个节点都具有相同的值,那么该二叉树就是单值二叉树. 只有给定的树是单值二叉树时,才返回 true:否则返回 false. 示例 1: 输入:[1,1,1,1,1,null,1] 输出:tr ...

  3. LeetCode965. 单值二叉树

    题目 1 class Solution { 2 public: 3 int flag = 0; 4 bool isUnivalTree(TreeNode* root){ 5 isUnivalTree1 ...

随机推荐

  1. sleep和 wait

  2. WPF SourceInitialized 事件

    这里先介绍一个窗体的事件SourceInitialized,这个时间发生在WPF窗体的资源初始化完毕,并且可以通过WindowInteropHelper获得该窗体的句柄用来与Win32交互. 具体可以 ...

  3. 实习第一天:try和catch的使用

    package wo;public class wowo{ public static void main(String[] args){ try{ // int i = 1/0; 是没有语法错误的, ...

  4. CentOS升级Python2.6到Python2.7并安装pip

    原文:http://ruter.sundaystart.net/2015/12/03/Update-python/ 貌似CentOS 6.X系统默认安装的Python都是2.6版本的?平时使用以及很多 ...

  5. day10 python学习 函数的嵌套命名空间作用域 三元运算 位置参数 默认参数 动态参数

    1.三元运算 #1.三元运算 利用已下方法就可以实现一步运算返回a b中大的值 def my_max(a,b): c=0 a=int(input('请输入')) b=int(input('请输入')) ...

  6. Javascript 正则验证带 + 号的邮箱地址

    很多邮箱地址是可以加上 + 加号为同一个邮箱地址. 比如 Gmail. 如果需要验证带 + 号的邮箱,如下: str = "65485+55@gmail.com"; documen ...

  7. oracle12c之 控制pdb中sga 与 pga 内存使用

    Memory Management using Resource Manager Oracle数据库资源管理器(资源管理器)现在可以在多租户容器数据库(CDB)中管理可插入数据库(PDBs)之间的内存 ...

  8. python版 google密码认证器

    #!/usr/bin/env python # -*- coding:utf-8 -*- import hmac, base64, struct, hashlib, time def calGoogl ...

  9. nginx定制header返回信息模块ngx_headers_more

    http://www.ttlsa.com/nginx/nginx-custom-header-to-return-information-module-ngx_headers_more/ 一. 介绍n ...

  10. Oracle根据表的大小排序SQL语句

    --按照数据行数排序select table_name,blocks,num_rows from dba_tables where owner not like '%SYS%' and table_n ...