1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-10-25 23:08:57 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
This commit is contained in:
2022-05-02 23:44:12 +08:00
parent 7ea03594b3
commit 2a71c78585
4790 changed files with 11696 additions and 10944 deletions

View File

@@ -12,7 +12,7 @@
"translatedContent": "<p>给定一个有 <code>N</code> 个结点的二叉树的根结点 <code>root</code>,树中的每个结点上都对应有 <code>node.val</code> 枚硬币,并且总共有 <code>N</code> 枚硬币。</p>\n\n<p>在一次移动中,我们可以选择两个相邻的结点,然后将一枚硬币从其中一个结点移动到另一个结点。(移动可以是从父结点到子结点,或者从子结点移动到父结点。)。</p>\n\n<p>返回使每个结点上只有一枚硬币所需的移动次数。</p>\n\n<p>&nbsp;</p>\n\n<p><strong>示例 1</strong></p>\n\n<p><strong><img alt=\"\" src=\"https://assets.leetcode-cn.com/aliyun-lc-upload/uploads/2019/01/19/tree1.png\" style=\"height: 142px; width: 150px;\"></strong></p>\n\n<pre><strong>输入:</strong>[3,0,0]\n<strong>输出:</strong>2\n<strong>解释:</strong>从树的根结点开始,我们将一枚硬币移到它的左子结点上,一枚硬币移到它的右子结点上。\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/2019/01/19/tree2.png\" style=\"height: 142px; width: 150px;\"></strong></p>\n\n<pre><strong>输入:</strong>[0,3,0]\n<strong>输出:</strong>3\n<strong>解释:</strong>从根结点的左子结点开始,我们将两枚硬币移到根结点上 [移动两次]。然后,我们把一枚硬币从根结点移到右子结点上。\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/2019/01/19/tree3.png\" style=\"height: 142px; width: 150px;\"></strong></p>\n\n<pre><strong>输入:</strong>[1,0,2]\n<strong>输出:</strong>2\n</pre>\n\n<p><strong>示例 4</strong></p>\n\n<p><strong><img alt=\"\" src=\"https://assets.leetcode-cn.com/aliyun-lc-upload/uploads/2019/01/19/tree4.png\" style=\"height: 156px; width: 155px;\"></strong></p>\n\n<pre><strong>输入:</strong>[1,0,0,null,3]\n<strong>输出:</strong>4\n</pre>\n\n<p>&nbsp;</p>\n\n<p><strong>提示:</strong></p>\n\n<ol>\n\t<li><code>1&lt;= N &lt;= 100</code></li>\n\t<li><code>0 &lt;= node.val &lt;= N</code></li>\n</ol>\n",
"isPaidOnly": false,
"difficulty": "Medium",
"likes": 292,
"likes": 296,
"dislikes": 0,
"isLiked": null,
"similarQuestions": "[{\"title\": \"Sum of Distances in Tree\", \"titleSlug\": \"sum-of-distances-in-tree\", \"difficulty\": \"Hard\", \"translatedTitle\": \"\\u6811\\u4e2d\\u8ddd\\u79bb\\u4e4b\\u548c\"}, {\"title\": \"Binary Tree Cameras\", \"titleSlug\": \"binary-tree-cameras\", \"difficulty\": \"Hard\", \"translatedTitle\": \"\\u76d1\\u63a7\\u4e8c\\u53c9\\u6811\"}]",
@@ -149,7 +149,7 @@
"__typename": "CodeSnippetNode"
}
],
"stats": "{\"totalAccepted\": \"9.9K\", \"totalSubmission\": \"13.8K\", \"totalAcceptedRaw\": 9903, \"totalSubmissionRaw\": 13766, \"acRate\": \"71.9%\"}",
"stats": "{\"totalAccepted\": \"10.2K\", \"totalSubmission\": \"14.2K\", \"totalAcceptedRaw\": 10154, \"totalSubmissionRaw\": 14154, \"acRate\": \"71.7%\"}",
"hints": [],
"solution": {
"id": "125",