15. 3Sum
Practice 3Sum for free on NudgeCode: Medium, Two Pointers pattern. Write it in Python or JavaScript, run the tests in your browser, and ask for a hint when you are stuck.
Return all distinct triplets [a, b, c] from nums (using three different indices) whose sum is 0. The answer must not contain duplicate triplets; order doesn't matter.
Example
nums = [-1,0,1,2,-1,-4] -> [[-1,-1,2],[-1,0,1]]
Constraints
- 3 <= nums.length <= 3000