mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-09-05 23:41:41 +08:00
update
This commit is contained in:
@@ -9,10 +9,10 @@
|
||||
"titleSlug": "construct-string-from-binary-tree",
|
||||
"content": "<p>Given the <code>root</code> of a binary tree, construct a string consisting of parenthesis and integers from a binary tree with the preorder traversal way, and return it.</p>\n\n<p>Omit all the empty parenthesis pairs that do not affect the one-to-one mapping relationship between the string and the original binary tree.</p>\n\n<p> </p>\n<p><strong>Example 1:</strong></p>\n<img alt=\"\" src=\"https://assets.leetcode.com/uploads/2021/05/03/cons1-tree.jpg\" style=\"width: 292px; height: 301px;\" />\n<pre>\n<strong>Input:</strong> root = [1,2,3,4]\n<strong>Output:</strong> "1(2(4))(3)"\n<strong>Explanation:</strong> Originally, it needs to be "1(2(4)())(3()())", but you need to omit all the unnecessary empty parenthesis pairs. And it will be "1(2(4))(3)"\n</pre>\n\n<p><strong>Example 2:</strong></p>\n<img alt=\"\" src=\"https://assets.leetcode.com/uploads/2021/05/03/cons2-tree.jpg\" style=\"width: 207px; height: 293px;\" />\n<pre>\n<strong>Input:</strong> root = [1,2,3,null,4]\n<strong>Output:</strong> "1(2()(4))(3)"\n<strong>Explanation:</strong> Almost the same as the first example, except we cannot omit the first parenthesis pair to break the one-to-one mapping relationship between the input and the output.\n</pre>\n\n<p> </p>\n<p><strong>Constraints:</strong></p>\n\n<ul>\n\t<li>The number of nodes in the tree is in the range <code>[1, 10<sup>4</sup>]</code>.</li>\n\t<li><code>-1000 <= Node.val <= 1000</code></li>\n</ul>\n",
|
||||
"translatedTitle": "根据二叉树创建字符串",
|
||||
"translatedContent": "<p>你需要采用前序遍历的方式,将一个二叉树转换成一个由括号和整数组成的字符串。</p>\n\n<p>空节点则用一对空括号 "()" 表示。而且你需要省略所有不影响字符串与原始二叉树之间的一对一映射关系的空括号对。</p>\n\n<p><strong>示例 1:</strong></p>\n\n<pre>\n<strong>输入:</strong> 二叉树: [1,2,3,4]\n 1\n / \\\n 2 3\n / \n 4 \n\n<strong>输出:</strong> "1(2(4))(3)"\n\n<strong>解释:</strong> 原本将是“1(2(4)())(3())”,\n在你省略所有不必要的空括号对之后,\n它将是“1(2(4))(3)”。\n</pre>\n\n<p><strong>示例 2:</strong></p>\n\n<pre>\n<strong>输入:</strong> 二叉树: [1,2,3,null,4]\n 1\n / \\\n 2 3\n \\ \n 4 \n\n<strong>输出:</strong> "1(2()(4))(3)"\n\n<strong>解释:</strong> 和第一个示例相似,\n除了我们不能省略第一个对括号来中断输入和输出之间的一对一映射关系。\n</pre>\n",
|
||||
"translatedContent": "<p>给你二叉树的根节点 <code>root</code> ,请你采用前序遍历的方式,将二叉树转化为一个由括号和整数组成的字符串,返回构造出的字符串。</p>\n\n<p>空节点使用一对空括号对 <code>\"()\"</code> 表示,转化后需要省略所有不影响字符串与原始二叉树之间的一对一映射关系的空括号对。</p>\n\n<div class=\"original__bRMd\">\n<div>\n<p> </p>\n\n<p><strong>示例 1:</strong></p>\n<img alt=\"\" src=\"https://assets.leetcode.com/uploads/2021/05/03/cons1-tree.jpg\" style=\"width: 292px; height: 301px;\" />\n<pre>\n<strong>输入:</strong>root = [1,2,3,4]\n<strong>输出:</strong>\"1(2(4))(3)\"\n<strong>解释:</strong>初步转化后得到 \"1(2(4)())(3()())\" ,但省略所有不必要的空括号对后,字符串应该是\"1(2(4))(3)\" 。\n</pre>\n\n<p><strong>示例 2:</strong></p>\n<img alt=\"\" src=\"https://assets.leetcode.com/uploads/2021/05/03/cons2-tree.jpg\" style=\"width: 207px; height: 293px;\" />\n<pre>\n<strong>输入:</strong>root = [1,2,3,null,4]\n<strong>输出:</strong>\"1(2()(4))(3)\"\n<strong>解释:</strong>和第一个示例类似,但是无法省略第一个空括号对,否则会破坏输入与输出一一映射的关系。</pre>\n\n<p> </p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li>树中节点的数目范围是 <code>[1, 10<sup>4</sup>]</code></li>\n\t<li><code>-1000 <= Node.val <= 1000</code></li>\n</ul>\n</div>\n</div>\n",
|
||||
"isPaidOnly": false,
|
||||
"difficulty": "Easy",
|
||||
"likes": 315,
|
||||
"likes": 323,
|
||||
"dislikes": 0,
|
||||
"isLiked": null,
|
||||
"similarQuestions": "[{\"title\": \"Construct Binary Tree from String\", \"titleSlug\": \"construct-binary-tree-from-string\", \"difficulty\": \"Medium\", \"translatedTitle\": \"\\u4ece\\u5b57\\u7b26\\u4e32\\u751f\\u6210\\u4e8c\\u53c9\\u6811\"}, {\"title\": \"Find Duplicate Subtrees\", \"titleSlug\": \"find-duplicate-subtrees\", \"difficulty\": \"Medium\", \"translatedTitle\": \"\\u5bfb\\u627e\\u91cd\\u590d\\u7684\\u5b50\\u6811\"}]",
|
||||
@@ -155,7 +155,7 @@
|
||||
"__typename": "CodeSnippetNode"
|
||||
}
|
||||
],
|
||||
"stats": "{\"totalAccepted\": \"59.6K\", \"totalSubmission\": \"94.4K\", \"totalAcceptedRaw\": 59551, \"totalSubmissionRaw\": 94355, \"acRate\": \"63.1%\"}",
|
||||
"stats": "{\"totalAccepted\": \"60.7K\", \"totalSubmission\": \"96.2K\", \"totalAcceptedRaw\": 60691, \"totalSubmissionRaw\": 96195, \"acRate\": \"63.1%\"}",
|
||||
"hints": [],
|
||||
"solution": null,
|
||||
"status": null,
|
||||
|
Reference in New Issue
Block a user