Microsoft Interview Question

Question on Stack and Dynamic Programming