Sollicitatievraag bij Google

They asked a coding problem based on dp