mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-09-02 22:13:28 +08:00
update
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
"translatedContent": "<p>如果一棵二叉树满足下述几个条件,则可以称为 <strong>奇偶树</strong> :</p>\n\n<ul>\n\t<li>二叉树根节点所在层下标为 <code>0</code> ,根的子节点所在层下标为 <code>1</code> ,根的孙节点所在层下标为 <code>2</code> ,依此类推。</li>\n\t<li><strong>偶数下标</strong> 层上的所有节点的值都是 <strong>奇</strong> 整数,从左到右按顺序 <strong>严格递增</strong></li>\n\t<li><strong>奇数下标</strong> 层上的所有节点的值都是 <strong>偶</strong> 整数,从左到右按顺序 <strong>严格递减</strong></li>\n</ul>\n\n<p>给你二叉树的根节点,如果二叉树为 <strong>奇偶树 </strong>,则返回 <code>true</code> ,否则返回 <code>false</code> 。</p>\n\n<p> </p>\n\n<p><strong>示例 1:</strong></p>\n\n<p><strong><img alt=\"\" src=\"https://assets.leetcode-cn.com/aliyun-lc-upload/uploads/2020/10/04/sample_1_1966.png\" style=\"height: 229px; width: 362px;\" /></strong></p>\n\n<pre>\n<strong>输入:</strong>root = [1,10,4,3,null,7,9,12,8,6,null,null,2]\n<strong>输出:</strong>true\n<strong>解释:</strong>每一层的节点值分别是:\n0 层:[1]\n1 层:[10,4]\n2 层:[3,7,9]\n3 层:[12,8,6,2]\n由于 0 层和 2 层上的节点值都是奇数且严格递增,而 1 层和 3 层上的节点值都是偶数且严格递减,因此这是一棵奇偶树。\n</pre>\n\n<p><strong>示例 2:</strong></p>\n\n<p><strong><img alt=\"\" src=\"https://assets.leetcode-cn.com/aliyun-lc-upload/uploads/2020/10/04/sample_2_1966.png\" style=\"height: 167px; width: 363px;\" /></strong></p>\n\n<pre>\n<strong>输入:</strong>root = [5,4,2,3,3,7]\n<strong>输出:</strong>false\n<strong>解释:</strong>每一层的节点值分别是:\n0 层:[5]\n1 层:[4,2]\n2 层:[3,3,7]\n2 层上的节点值不满足严格递增的条件,所以这不是一棵奇偶树。\n</pre>\n\n<p><strong>示例 3:</strong></p>\n\n<p><img alt=\"\" src=\"https://assets.leetcode-cn.com/aliyun-lc-upload/uploads/2020/10/04/sample_1_333_1966.png\" style=\"height: 167px; width: 363px;\" /></p>\n\n<pre>\n<strong>输入:</strong>root = [5,9,1,3,5,7]\n<strong>输出:</strong>false\n<strong>解释:</strong>1 层上的节点值应为偶数。\n</pre>\n\n<p><strong>示例 4:</strong></p>\n\n<pre>\n<strong>输入:</strong>root = [1]\n<strong>输出:</strong>true\n</pre>\n\n<p><strong>示例 5:</strong></p>\n\n<pre>\n<strong>输入:</strong>root = [11,8,6,1,3,9,11,30,20,18,16,12,10,4,2,17]\n<strong>输出:</strong>true\n</pre>\n\n<p> </p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li>树中节点数在范围 <code>[1, 10<sup>5</sup>]</code> 内</li>\n\t<li><code>1 <= Node.val <= 10<sup>6</sup></code></li>\n</ul>\n",
|
||||
"isPaidOnly": false,
|
||||
"difficulty": "Medium",
|
||||
"likes": 71,
|
||||
"likes": 72,
|
||||
"dislikes": 0,
|
||||
"isLiked": null,
|
||||
"similarQuestions": "[]",
|
||||
@@ -149,7 +149,7 @@
|
||||
"__typename": "CodeSnippetNode"
|
||||
}
|
||||
],
|
||||
"stats": "{\"totalAccepted\": \"28.3K\", \"totalSubmission\": \"47.9K\", \"totalAcceptedRaw\": 28302, \"totalSubmissionRaw\": 47892, \"acRate\": \"59.1%\"}",
|
||||
"stats": "{\"totalAccepted\": \"29K\", \"totalSubmission\": \"49.1K\", \"totalAcceptedRaw\": 28997, \"totalSubmissionRaw\": 49117, \"acRate\": \"59.0%\"}",
|
||||
"hints": [
|
||||
"Use the breadth-first search to go through all nodes layer by layer."
|
||||
],
|
||||
|
Reference in New Issue
Block a user