Algorithm · Waymo · Medium
Problem: Filter an N-ary Tree and Render It with Indentation You receive an N-ary tree in which every node contains: value: a string children: an array of child nodes You also receive a string named query. Build a program that performs these operations: Discard the complete subtree of every node whose value includes query as a substring. Produce the resulting forest. If the original root is discarded, the result can contain no nodes. Print the nodes that remain in preorder.…