Sollicitatievraag bij Amazon

Question based on stacks and then dynamic programming