# Leetcode 606 - Construct String from Binary Tree

Note:

• Given traveral is in level order traversal.
• Normally it’d be quite easy, but when do we need to omit () and when not?
• Ask ourself when do we need null in our input?
• Ans: when we need to tell machine that left subtree is empty and the next node is for right subtree.
• So in our recursion, when a node has no left subtree but has right subtree, we cannot omit ().

Question:

Given the root of a binary tree, construct a string consisting of parenthesis and integers from a binary tree with the preorder traversal way, and return it.

Omit all the empty parenthesis pairs that do not affect the one-to-one mapping relationship between the string and the original binary tree.

Example:

Code: