Medium · Two pointers

3Sum

You are given a list of integers. Return every set of three of them, taken from different positions, that adds up to zero.

  • The same three values are listed once, however many ways they can be picked.
  • The triplets can be in any order, and so can the numbers inside one.
  • If there are none, return an empty list.
nums = [-1, 0, 1, 2, -1, -4]

→ [[-1, -1, 2], [-1, 0, 1]]
Record your take

No one has solved it yet.