Niantic Interview Question

DP problem, binary tree problem