Skip to content

Commit 6794740

Browse files
refactor 333
1 parent 99253cd commit 6794740

File tree

1 file changed

+3
-22
lines changed
  • src/main/java/com/fishercoder/solutions

1 file changed

+3
-22
lines changed

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

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

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

5-
/**333. Largest BST Subtree
6-
*
7-
* Given a binary tree, find the largest subtree which is a Binary Search Tree (BST),
8-
* where largest means subtree with largest number of nodes in it.
9-
10-
Note:
11-
A subtree must include all of its descendants.
12-
Here's an example:
13-
10
14-
/ \
15-
5 15
16-
/ \ \
17-
1 8 7
18-
19-
The Largest BST Subtree in this case is the highlighted one (5,1,8).
20-
The return value is the subtree's size, which is 3.
21-
22-
Follow up:
23-
Can you figure out ways to solve it with O(n) time complexity?
24-
*/
25-
265
public class _333 {
276
public static class Solution1 {
28-
/**credit: https://discuss.leetcode.com/topic/36995/share-my-o-n-java-code-with-brief-explanation-and-comments*/
7+
/**
8+
* credit: https://discuss.leetcode.com/topic/36995/share-my-o-n-java-code-with-brief-explanation-and-comments
9+
*/
2910
class Result { // (size, rangeLower, rangeUpper) -- size of current tree, range of current tree [rangeLower, rangeUpper]
3011
int size;
3112
int lower;

0 commit comments

Comments
 (0)