Amazon Interview Question

It was a generic two-pointer problem.