Back to problems

N-ary Tree Sum + Leaf `next` Pointer

Algorithm · Citadel · Hard

Requirements This one-hour live-coding exercise focuses on trees and data structures. Work through the following three-stage progression: Create the node and aggregate values. Define a node representation for a general rooted tree. The tree need not be binary, so each node may store a collection of children. Compute and return the sum of every node's value. Chain leaves in DFS order. Extend each node with a next pointer. Once traversal finishes, each leaf must reference the…

Checking your access…