Leetcode 2458. Height of Binary Tree After Subtree Removal Queries
Given a rooted binary tree and m independent queries that remove the entire subtree rooted at a specified node (never the root), return the tree height after each removal. The core challenge is to preprocess depths and subtree heights (n up to 1e5, m up to 1e4) so you can compute each query’s new root-to-leaf longest path efficiently without recomputing the whole tree.
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
0
Hello Interview Premium
Your account is free and you can post anonymously if you choose.