解題說明
C++ 解法
複雜度分析
虛擬碼
1. If root is null, return empty string
2. result = string(root.val)
3. If left child exists OR right child exists:
a. result += "(" + tree2str(left) + ")"
4. If right child exists:
a. result += "(" + tree2str(right) + ")"
5. Return result