Amazon Interview Question

Question relate to dynamic algorithms