<jupyter_start><jupyter_text>https://leetcode.com/problems/validate-binary-search-tree/https://docs.google.com/document/d/1q__2T-MBXXi-oGRWMqtVUCWEoVNRJS_8akoy2_OYy_s/edit I could not figure out the BST Validator solution by myself but I did figure out how to validate max heaps<jupyter_code># actual soltution
def isValidBST(root) -> bool:
    def helper(node):
        if not node:
            return float('inf'), float('-inf'), True
        min_l, max_l, flag_l = helper(node.left)
        min_r, max_r, flag_r = helper(node.right)
        if (max_l < node.val < min_r) and flag_l and flag_r:
            return min(min_l,node.val), max(max_r,node.val), True
        else:
            return -1,-1,False
    _,_,f = helper(root)
    return f

# max heap validator

def isValidMaxHeap(self, root) -> bool:
    def helper(root):
        if root.left and root.val < root.left.val:
            return False
        elif root.right and root.val > root.right.val:
            return False
        else:
            return True

    return helper(root.left) and helper(root.right)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.10749774164408311, 'fraction_numerical': 0.005420054200542005, 'mean_word_length': 2.681063122923588, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '103136', 'license': 'MIT', 'n_tokens_mistral': 382, 'n_tokens_neox': 377, 'n_words': 93, 'path': 'lt98_validate_binary_search_tree.ipynb', 'repo_name': 'devkosal/code_challenges', 'size': '1107'}