Amazon Interview Question

Stock buy sell 3 Dynamic Programing Problem and Valid parenthesis(modified one)