Amazon interview question

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