3Sum (Find All Triplets)

00:00
MediumArrayTwo PointersSorting
AmazonAdobe

Find all unique triplets [a,b,c] in the array such that a+b+c=0. Solution set must not contain duplicate triplets.

Examples

Input → [-1,0,1,2,-1,-4]
Output → [[-1,-1,2],[-1,0,1]]
Input → [0,1,1]
Output → []
Input → [0,0,0]
Output → [[0,0,0]]