Microsoft interview question

Tree algorithm, DP,