Sort the array, then for each fixed first element use a two-pointer scan to find pairs that complete sum 0.
i over possible first elements, skipping duplicates.l=i+1, r=n-1. Move pointers based on the sum.l and r.Sorting enables the two-pointer technique and makes duplicate skipping straightforward.
Sort the array, then for each fixed first element use a two-pointer scan to find pairs that complete sum 0.
i over possible first elements, skipping duplicates.l=i+1, r=n-1. Move pointers based on the sum.l and r.Sorting enables the two-pointer technique and makes duplicate skipping straightforward.