Domanda di colloquio di Amazon

First question was based on the binary search Second was a DP problem with binary tree.