Google interview question

Dynamic Programing on first interview Trees in the second