Skip to content
This repository was archived by the owner on Aug 14, 2024. It is now read-only.

Latest commit

 

History

History
24 lines (16 loc) · 444 Bytes

333.md

File metadata and controls

24 lines (16 loc) · 444 Bytes

333. Largest BST Subtree

Description

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   7

The Largest BST Subtree in this case is the highlighted one.

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

**