We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 1cf946a commit 9531c2aCopy full SHA for 9531c2a
solution/0669.Trim a Binary Search Tree/Solution.java
@@ -0,0 +1,10 @@
1
+class Solution {
2
+ public TreeNode trimBST(TreeNode root, int L, int R) {
3
+ if (root == null) return null;
4
+ if (root.val < L) return trimBST(root.right, L, R);
5
+ if (root.val > R) return trimBST(root.left, L, R);
6
+ root.left = trimBST(root.left, L, R);
7
+ root.right = trimBST(root.right, L, R);
8
+ return root;
9
+ }
10
+}
0 commit comments