Microsoft Interview Question

Tree algorithm, DP,