Amazon interview question

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