Robbing a Tree

Asked at Zip · Coding Questions · Difficulty: Medium · Last asked Jul 15, 2026

In a village structured as a tree, each node represents a house containing certain wealth. The village is structured as a general tree and not a binary tree. Your task is to collect the maximum amount of wealth, but you cannot rob two directly connected houses. Write a function to calculate the maximum wealth that can be obtained from this tree.

Loading the problem…