← Questions

Maximum sum of non-adjacent houses, on a line, a circle and a tree

0
DatabricksAmazonAirbnb+1CodingLast asked Jan 2026

Each house holds some value and you cannot take two neighbours. Find the best total for houses in a row, then for houses arranged in a circle, then for houses arranged as a binary tree where parent and child count as neighbours.

Write and test your solution herePython in your browser, the question's tests level by level, saved for you.Sign in to start coding