File tree 1 file changed +0
-23
lines changed
src/main/java/com/fishercoder/solutions
1 file changed +0
-23
lines changed Original file line number Diff line number Diff line change 5
5
import java .util .ArrayDeque ;
6
6
import java .util .Deque ;
7
7
8
- /**
9
- * 536. Construct Binary Tree from String
10
- *
11
- * You need to construct a binary tree from a string consisting of parenthesis and integers.
12
- The whole input represents a binary tree. It contains an integer followed by zero, one or two pairs of parenthesis.
13
- The integer represents the root's value and a pair of parenthesis contains a child binary tree with the same structure.
14
- You always start to construct the left child node of the parent first if it exists.
15
-
16
- Example:
17
- Input: "4(2(3)(1))(6(5))"
18
- Output: return the tree root node representing the following tree:
19
-
20
- 4
21
- / \
22
- 2 6
23
- / \ /
24
- 3 1 5
25
-
26
- Note:
27
- There will only be '(', ')', '-' and '0' ~ '9' in the input string.
28
- An empty tree is represented by "" instead of "()".
29
- */
30
-
31
8
public class _536 {
32
9
33
10
public static class Solution1 {
You can’t perform that action at this time.
0 commit comments