Capital One interview question

Array, Greedy, Sorting, two pointers