Morgan Stanley Interview Question

dsa questions one was dp and another was from binary search tree