Skip to content

Commit 195dd99

Browse files
refactor 1008
1 parent cd05953 commit 195dd99

File tree

1 file changed

+3
-24
lines changed

1 file changed

+3
-24
lines changed

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

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,11 @@
22

33
import com.fishercoder.common.classes.TreeNode;
44

5-
/**
6-
* 1008. Construct Binary Search Tree from Preorder Traversal
7-
*
8-
* Return the root node of a binary search tree that matches the given preorder traversal.
9-
* (Recall that a binary search tree is a binary tree where for every node, any descendant of node.left has a value < node.val, and any descendant of node.right has a value > node.val.
10-
* Also recall that a preorder traversal displays the value of the node first, then traverses node.left, then traverses node.right.)
11-
*
12-
* Example 1:
13-
*
14-
* Input: [8,5,1,7,10,12]
15-
* Output: [8,5,10,1,7,null,12]
16-
*
17-
* 8
18-
* / \
19-
* 5 10
20-
* / \ \
21-
* 1 7 12
22-
*
23-
* Note:
24-
*
25-
* 1 <= preorder.length <= 100
26-
* The values of preorder are distinct.
27-
* */
285
public class _1008 {
296
public static class Solution1 {
30-
/**credit: https://leetcode.com/problems/construct-binary-search-tree-from-preorder-traversal/discuss/252232/JavaC%2B%2BPython-O(N)-Solution*/
7+
/**
8+
* credit: https://leetcode.com/problems/construct-binary-search-tree-from-preorder-traversal/discuss/252232/JavaC%2B%2BPython-O(N)-Solution
9+
*/
3110
int i = 0;
3211

3312
public TreeNode bstFromPreorder(int[] preorder) {

0 commit comments

Comments
 (0)