Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit195dd99

Browse files
refactor 1008
1 parentcd05953 commit195dd99

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
importcom.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
publicclass_1008 {
296
publicstaticclassSolution1 {
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
inti =0;
3211

3312
publicTreeNodebstFromPreorder(int[]preorder) {

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp