Capital One interview question

Array manipulation and dynamic programming.