height of binary tree queries
2458. Height of Binary Tree After Subtree Removal Queries Solved Hard Topics Companies Hint You are given the root of a binary tree with n nodes. Each node is assigned a unique value from 1 to n . You are also given an array queries of size m . You have to perform m independent queries on the tree where in the i th query you do the following: Remove the subtree rooted at the node with the value queries[i] from the tree. It is guaranteed that queries[i] will not be equal to the value of the root. Return an array answer of size m where answer[i] is the height of the tree after performing the i th query . Note : The queries are independent, so the tree returns to its initial state after each query. The height of a tree is the number of edges in the longest s...