Back to problems

Repeatedly Delete Leaves Matching a Target Value From a Binary Tree

Algorithm · Google · Medium

Given a binary tree represented as a level-order list and an integer target, remove every leaf whose value is target. After such leaves are removed, a parent may become a leaf; if that parent also has value target, remove it as well. Continue this process until no remaining leaf has the value target. Return the resulting tree in the same level-order encoding. If the root itself is removed, return []. Implement the function: Tree Encoding The input and output share the same…

Checking your access…