File tree Expand file tree Collapse file tree 1 file changed +0
-44
lines changed
src/main/java/com/fishercoder/solutions Expand file tree Collapse file tree 1 file changed +0
-44
lines changed Original file line number Diff line number Diff line change 2
2
3
3
import com .fishercoder .common .classes .TreeNode ;
4
4
5
- /**
6
- * 669. Trim a Binary Search Tree
7
- *
8
- * Given a binary search tree and the lowest and highest boundaries as L and R,
9
- * trim the tree so that all its elements lies in [L, R] (R >= L).
10
- * You might need to change the root of the tree, so the result should return the new root of the trimmed binary search tree.
11
-
12
- Example 1:
13
-
14
- Input:
15
- 1
16
- / \
17
- 0 2
18
-
19
- L = 1
20
- R = 2
21
-
22
- Output:
23
- 1
24
- \
25
- 2
26
-
27
- Example 2:
28
-
29
- Input:
30
- 3
31
- / \
32
- 0 4
33
- \
34
- 2
35
- /
36
- 1
37
-
38
- L = 1
39
- R = 3
40
-
41
- Output:
42
- 3
43
- /
44
- 2
45
- /
46
- 1
47
-
48
- */
49
5
public class _669 {
50
6
public static class Solution1 {
51
7
public TreeNode trimBST (TreeNode root , int L , int R ) {
You can’t perform that action at this time.
0 commit comments