This website contains ALL LeetCode **Premium** problems for
**FREE!!**.

All leaked interview problems are collected from Internet.

All leaked interview problems are collected from Internet.

Given a binary tree, find the largest subtree which is a Binary Search Tree (BST), where largest means subtree with largest number of nodes in it.

**Note:**

A subtree must include all of its descendants.

Here's an example:

10 / \ 5 15 / \ \ 1 8 7The Largest BST Subtree in this case is the highlighted one.

The return value is the subtree's size, which is 3.

**Follow up:**

Can you figure out ways to solve it with O(n) time complexity?

b''