Pregunta de entrevista de Amazon

Question relate to dynamic algorithms