Amazon interview question

Question relate to dynamic algorithms