606. Construct String from Binary Tree
题目描述
You need to construct a string consists of parenthesis and integers from a binary tree with the preorder traversing way.
The null node needs to be represented by empty parenthesis pair “()”. And you need to omit all the empty parenthesis pairs that don’t affect the one-to-one mapping relationship between the string and the original binary tree.
|
|
|
|
题目大意
将二叉树转换为字符串,转换规则为root(left)(right),以此类推
解题思路
递归
ps:不知道该咋说,代码一目了然。
代码
|
|