Back to problems

Menu Tree Diff — Count Changed Nodes

Algorithm · DoorDash · Hard

Requirements Treat each menu as a tree. A node contains a key (such as a or b) along with a value; for instance, a(1) denotes key a with value 1. The old tree represents the menu currently stored by the system, while the updated tree is the merchant's latest submission. Determine the number of nodes that differ between them. The comparison receives two rooted trees, old_tree and updated_tree; each node has a key, a value, and zero or more child nodes. Return the result from…

Checking your access…