Skip to content

Commit 1db1c3c

Browse files
refactor 331
1 parent 8c9eff8 commit 1db1c3c

File tree

1 file changed

+0
-35
lines changed
  • src/main/java/com/fishercoder/solutions

1 file changed

+0
-35
lines changed

src/main/java/com/fishercoder/solutions/_331.java

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -3,41 +3,6 @@
33
import java.util.ArrayDeque;
44
import java.util.Deque;
55

6-
/**
7-
* 331. Verify Preorder Serialization of a Binary Tree
8-
*
9-
* One way to serialize a binary tree is to use pre-order traversal. When we encounter a non-null node, we record the node's value. If it is a null node, we record using a sentinel value such as #.
10-
11-
_9_
12-
/ \
13-
3 2
14-
/ \ / \
15-
4 1 # 6
16-
/ \ / \ / \
17-
# # # # # #
18-
19-
For example, the above binary tree can be serialized to the string "9,3,4,#,#,1,#,#,2,#,6,#,#", where # represents a null node.
20-
21-
Given a string of comma separated values, verify whether it is a correct preorder traversal serialization of a binary tree. Find an algorithm without reconstructing the tree.
22-
23-
Each comma separated value in the string must be either an integer or a character '#' representing null pointer.
24-
25-
You may assume that the input format is always valid, for example it could never contain two consecutive commas such as "1,,3".
26-
27-
Example 1:
28-
"9,3,4,#,#,1,#,#,2,#,6,#,#"
29-
Return true
30-
31-
Example 2:
32-
"1,#"
33-
Return false
34-
35-
Example 3:
36-
"9,#,#,1"
37-
Return false
38-
39-
40-
*/
416
public class _331 {
427

438
public static class Solution1 {

0 commit comments

Comments
 (0)