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

0
Practice

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.

DatabricksCodingMediumLast asked Nov 2025
No answer yet. Write the first one; the best answer gets endorsed.