Maximize stock profit with constraints | Amazon Interview Question