sau_tim_thiep_hong
Member
Python:
class Solution:
def tree2str(self, root: Optional[TreeNode]) -> str:
if root is None: return ""
if root.left is None and root.right is None: return str(root.val)
return str(root.val) + "(" + self.tree2str(root.left) +")" + ("" if root.right is None else "(" + self.tree2str(root.right) +")")


