1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-09-14 11:51:42 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee

add leetcode problem-cn part3

This commit is contained in:
2022-03-27 20:46:41 +08:00
parent 6dafca13c5
commit dfacb20d31
1385 changed files with 115239 additions and 3 deletions

View File

@@ -0,0 +1,36 @@
<p>你需要采用前序遍历的方式,将一个二叉树转换成一个由括号和整数组成的字符串。</p>
<p>空节点则用一对空括号 &quot;()&quot; 表示。而且你需要省略所有不影响字符串与原始二叉树之间的一对一映射关系的空括号对。</p>
<p><strong>示例 1:</strong></p>
<pre>
<strong>输入:</strong> 二叉树: [1,2,3,4]
1
/ \
2 3
/
4
<strong>输出:</strong> &quot;1(2(4))(3)&quot;
<strong>解释:</strong> 原本将是&ldquo;1(2(4)())(3())&rdquo;
在你省略所有不必要的空括号对之后,
它将是&ldquo;1(2(4))(3)&rdquo;
</pre>
<p><strong>示例 2:</strong></p>
<pre>
<strong>输入:</strong> 二叉树: [1,2,3,null,4]
1
/ \
2 3
\
4
<strong>输出:</strong> &quot;1(2()(4))(3)&quot;
<strong>解释:</strong> 和第一个示例相似,
除了我们不能省略第一个对括号来中断输入和输出之间的一对一映射关系。
</pre>