Google Interview Question

Tree construction and traversal, traveling knapsack-like problem, DP. Leetcode medium-hard.