mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-10-21 13:06:47 +08:00
update
This commit is contained in:
@@ -12,12 +12,12 @@
|
||||
"translatedContent": "<p>表:<code>Tree</code></p>\n\n<pre>\n+-------------+------+\n| Column Name | Type |\n+-------------+------+\n| id | int |\n| p_id | int |\n+-------------+------+\nid 是该表中具有唯一值的列。\n该表的每行包含树中节点的 id 及其父节点的 id 信息。\n给定的结构总是一个有效的树。\n</pre>\n\n<p> </p>\n\n<p>树中的每个节点可以是以下三种类型之一:</p>\n\n<ul>\n\t<li><strong>\"Leaf\"</strong>:节点是叶子节点。</li>\n\t<li><strong>\"Root\"</strong>:节点是树的根节点。</li>\n\t<li><strong>\"lnner\"</strong>:节点既不是叶子节点也不是根节点。</li>\n</ul>\n\n<p>编写一个解决方案来报告树中每个节点的类型。</p>\n\n<p>以 <strong>任意顺序</strong> 返回结果表。</p>\n\n<p>结果格式如下所示。</p>\n\n<p> </p>\n\n<p><strong class=\"example\">示例 1:</strong></p>\n<img alt=\"\" src=\"https://assets.leetcode.com/uploads/2021/10/22/tree1.jpg\" style=\"width: 304px; height: 224px;\" />\n<pre>\n<b>输入:</b>\nTree table:\n+----+------+\n| id | p_id |\n+----+------+\n| 1 | null |\n| 2 | 1 |\n| 3 | 1 |\n| 4 | 2 |\n| 5 | 2 |\n+----+------+\n<b>输出:</b>\n+----+-------+\n| id | type |\n+----+-------+\n| 1 | Root |\n| 2 | Inner |\n| 3 | Leaf |\n| 4 | Leaf |\n| 5 | Leaf |\n+----+-------+\n<b>解释:</b>\n节点 1 是根节点,因为它的父节点为空,并且它有子节点 2 和 3。\n节点 2 是一个内部节点,因为它有父节点 1 和子节点 4 和 5。\n节点 3、4 和 5 是叶子节点,因为它们有父节点而没有子节点。\n</pre>\n\n<p><strong class=\"example\">示例 2:</strong></p>\n<img alt=\"\" src=\"https://assets.leetcode.com/uploads/2021/10/22/tree2.jpg\" style=\"width: 64px; height: 65px;\" />\n<pre>\n<b>输入:</b>\nTree table:\n+----+------+\n| id | p_id |\n+----+------+\n| 1 | null |\n+----+------+\n<b>输出:</b>\n+----+-------+\n| id | type |\n+----+-------+\n| 1 | Root |\n+----+-------+\n<b>解释:</b>如果树中只有一个节点,则只需要输出其根属性。\n</pre>\n\n<p> </p>\n\n<p><strong>注意:</strong>本题与 <a href=\"https://leetcode.cn/problems/binary-tree-nodes/\">3054. 二叉树节点</a> 一致。</p>\n",
|
||||
"isPaidOnly": false,
|
||||
"difficulty": "Medium",
|
||||
"likes": 229,
|
||||
"likes": 240,
|
||||
"dislikes": 0,
|
||||
"isLiked": null,
|
||||
"similarQuestions": "[]",
|
||||
"contributors": [],
|
||||
"langToValidPlayground": "{\"cpp\": false, \"java\": false, \"python\": false, \"python3\": false, \"mysql\": false, \"mssql\": false, \"oraclesql\": false, \"c\": false, \"csharp\": false, \"javascript\": false, \"typescript\": false, \"bash\": false, \"php\": false, \"swift\": false, \"kotlin\": false, \"dart\": false, \"golang\": false, \"ruby\": false, \"scala\": false, \"html\": false, \"pythonml\": false, \"rust\": false, \"racket\": false, \"erlang\": false, \"elixir\": false, \"pythondata\": false, \"react\": false, \"vanillajs\": false, \"postgresql\": false, \"cangjie\": false}",
|
||||
"langToValidPlayground": "{\"cpp\": false, \"java\": false, \"python3\": false, \"python\": false, \"javascript\": false, \"typescript\": false, \"csharp\": false, \"c\": false, \"golang\": false, \"kotlin\": false, \"swift\": false, \"rust\": false, \"ruby\": false, \"php\": false, \"dart\": false, \"scala\": false, \"elixir\": false, \"erlang\": false, \"racket\": false, \"cangjie\": false, \"bash\": false, \"html\": false, \"pythonml\": false, \"react\": false, \"vanillajs\": false, \"mysql\": false, \"mssql\": false, \"postgresql\": false, \"oraclesql\": false, \"pythondata\": false}",
|
||||
"topicTags": [
|
||||
{
|
||||
"name": "Database",
|
||||
@@ -40,6 +40,12 @@
|
||||
"code": "/* Write your T-SQL query statement below */",
|
||||
"__typename": "CodeSnippetNode"
|
||||
},
|
||||
{
|
||||
"lang": "PostgreSQL",
|
||||
"langSlug": "postgresql",
|
||||
"code": "-- Write your PostgreSQL query statement below",
|
||||
"__typename": "CodeSnippetNode"
|
||||
},
|
||||
{
|
||||
"lang": "Oracle",
|
||||
"langSlug": "oraclesql",
|
||||
@@ -51,15 +57,9 @@
|
||||
"langSlug": "pythondata",
|
||||
"code": "import pandas as pd\n\ndef tree_node(tree: pd.DataFrame) -> pd.DataFrame:\n ",
|
||||
"__typename": "CodeSnippetNode"
|
||||
},
|
||||
{
|
||||
"lang": "PostgreSQL",
|
||||
"langSlug": "postgresql",
|
||||
"code": "-- Write your PostgreSQL query statement below",
|
||||
"__typename": "CodeSnippetNode"
|
||||
}
|
||||
],
|
||||
"stats": "{\"totalAccepted\": \"73.9K\", \"totalSubmission\": \"116.6K\", \"totalAcceptedRaw\": 73905, \"totalSubmissionRaw\": 116591, \"acRate\": \"63.4%\"}",
|
||||
"stats": "{\"totalAccepted\": \"81.3K\", \"totalSubmission\": \"126.8K\", \"totalAcceptedRaw\": 81339, \"totalSubmissionRaw\": 126803, \"acRate\": \"64.1%\"}",
|
||||
"hints": [
|
||||
"You can judge the node type by querying whether the node's id shows up in p_id column and whether the node's p_id is null."
|
||||
],
|
||||
|
Reference in New Issue
Block a user