mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-09-02 14:12:17 +08:00
update
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
"translatedContent": "<p>给你一棵以 <code>root</code> 为根的二叉树和一个整数 <code>target</code> ,请你删除所有值为 <code>target</code> 的 <strong>叶子节点</strong> 。</p>\n\n<p>注意,一旦删除值为 <code>target</code> 的叶子节点,它的父节点就可能变成叶子节点;如果新叶子节点的值恰好也是 <code>target</code> ,那么这个节点也应该被删除。</p>\n\n<p>也就是说,你需要重复此过程直到不能继续删除。</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/01/16/sample_1_1684.png\" style=\"height: 120px; width: 550px;\"></strong></p>\n\n<pre><strong>输入:</strong>root = [1,2,3,2,null,2,4], target = 2\n<strong>输出:</strong>[1,null,3,null,4]\n<strong>解释:\n</strong>上面左边的图中,绿色节点为叶子节点,且它们的值与 target 相同(同为 2 ),它们会被删除,得到中间的图。\n有一个新的节点变成了叶子节点且它的值与 target 相同,所以将再次进行删除,从而得到最右边的图。\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/01/16/sample_2_1684.png\" style=\"height: 120px; width: 300px;\"></strong></p>\n\n<pre><strong>输入:</strong>root = [1,3,3,3,2], target = 3\n<strong>输出:</strong>[1,3,null,null,2]\n</pre>\n\n<p><strong>示例 3:</strong></p>\n\n<p><strong><img alt=\"\" src=\"https://assets.leetcode-cn.com/aliyun-lc-upload/uploads/2020/01/16/sample_3_1684.png\" style=\"width: 450px;\"></strong></p>\n\n<pre><strong>输入:</strong>root = [1,2,null,2,null,2], target = 2\n<strong>输出:</strong>[1]\n<strong>解释:</strong>每一步都删除一个绿色的叶子节点(值为 2)。</pre>\n\n<p><strong>示例 4:</strong></p>\n\n<pre><strong>输入:</strong>root = [1,1,1], target = 1\n<strong>输出:</strong>[]\n</pre>\n\n<p><strong>示例 5:</strong></p>\n\n<pre><strong>输入:</strong>root = [1,2,3], target = 1\n<strong>输出:</strong>[1,2,3]\n</pre>\n\n<p> </p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li><code>1 <= target <= 1000</code></li>\n\t<li>每一棵树最多有 <code>3000</code> 个节点。</li>\n\t<li>每一个节点值的范围是 <code>[1, 1000]</code> 。</li>\n</ul>\n",
|
||||
"isPaidOnly": false,
|
||||
"difficulty": "Medium",
|
||||
"likes": 79,
|
||||
"likes": 80,
|
||||
"dislikes": 0,
|
||||
"isLiked": null,
|
||||
"similarQuestions": "[]",
|
||||
@@ -149,7 +149,7 @@
|
||||
"__typename": "CodeSnippetNode"
|
||||
}
|
||||
],
|
||||
"stats": "{\"totalAccepted\": \"12.3K\", \"totalSubmission\": \"16.8K\", \"totalAcceptedRaw\": 12304, \"totalSubmissionRaw\": 16829, \"acRate\": \"73.1%\"}",
|
||||
"stats": "{\"totalAccepted\": \"12.6K\", \"totalSubmission\": \"17.2K\", \"totalAcceptedRaw\": 12555, \"totalSubmissionRaw\": 17192, \"acRate\": \"73.0%\"}",
|
||||
"hints": [
|
||||
"Use the DFS to reconstruct the tree such that no leaf node is equal to the target. If the leaf node is equal to the target, return an empty object instead."
|
||||
],
|
||||
|
Reference in New Issue
Block a user