Amazon interview question

a problem similar to 3Sum.