HackerRank Interview Question

A DP problem and a binary tree problem