Practice Height of Binary Tree After Subtree Removal Queries
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Height of Binary Tree After Subtree Removal Queries
Problem Statement
For each queries value, independently remove the entire subtree rooted at the node with that value from root. Node values are unique and no query removes the root. Return the remaining tree height for each query, measured in edges from root to the deepest node. Restore the original tree before each next query.
Source: Height of Binary Tree After Subtree Removal Queries on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
root = [1,3,4,2,null,6,5,null,null,null,null,null,7], queries = [4]
[2]
# Example 2
root = [5,8,9,2,1,3,7,4,6], queries = [3,2,4,8]
[3,2,3,2]
Constraints
Related LeetCode Problems
Practice more problems similar to Height of Binary Tree After Subtree Removal Queries.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.