Google Interview Question

The technical question was on trees and Dp