Amazon Interview Question

one on stacks and one on dp