LeetCode 965. 单值二叉树
2022-5-25
| 2023-3-23
0  |  阅读时长 0 分钟
Created time
May 25, 2022 03:02 PM
date
status
category
Origin
summary
tags
type
URL
icon
password
slug

单值二叉树

如果二叉树每个节点都具有相同的值,那么该二叉树就是单值二叉树。只有给定的树是单值二叉树时,才返回 true;否则返回 false。给定树的节点数范围是 [1, 100]。每个节点的值都是整数,范围为 [0, 99] 。相关标签:树, 深度优先搜索, 广度优先搜索, 二叉树。

Univalued Binary Tree

A binary tree is uni-valued if every node in the tree has the same value. Given the root of a binary tree, return true if the given tree is uni-valued, or false otherwise. The number of nodes in the tree is in the range [1, 100]. 0 <= Node.val < 100. Related Topics: Tree, Depth-First Search, Breadth-First Search, Binary Tree.
这题是单值二叉树,让我们判断一下二叉树里面是不是只有一种值,写个深度优先搜索非常容易判断!判断所有值是不是都等于根节点的值就可以了。
LeetCode 467. 环绕字符串中唯一的子字符串LeetCode 462. 最少移动次数使数组元素相等 II
Loading...