Largest BST subtree

Write codeHard35 minMeta and Amazon style

Your task

Given a binary tree encoded as a level-order array (None marks a missing child), return the number of nodes in the largest subtree that is itself a valid binary search tree (strict ordering: left subtree values < node < right subtree values). Solve it bottom-up in a single post-order pass: each node returns whether its subtree is a BST, its size, and its min/max so the parent can decide in O(1). Return the size of the largest such subtree.

Examples

largest_bst_subtree(level: list) -> int
Example 1
Inputlargest_bst_subtree([10, 5, 15, 1, 8, None, 7])
Output3