Amazon Interview Question

a problem similar to 3Sum.