Problem
You get an integer array nums. Find each triplet with the sum 0. A triplet is a group of three items at three different positions in nums.
Return the values of these triplets. The answer must not contain two triplets with the same values. You can return the triplets in any order, and the values in each triplet in any order.
Example 1
- Input:
- nums = [-2,0,1,1,2]
- Output:
- [[-2,0,2],[-2,1,1]]
- Explanation:
- The sums of
[-2, 0, 2]and[-2, 1, 1]are 0. No other triplet has the sum 0.
Example 2
- Input:
- nums = [1,2,-4]
- Output:
- []
- Explanation:
- The only triplet has the sum -1, so the answer is empty.
Example 3
- Input:
- nums = [0,0,0,0]
- Output:
- [[0,0,0]]
- Explanation:
- Many groups of positions give
[0, 0, 0]. The answer contains this triplet only one time.
Constraints
- 3 <= nums.length <= 3000
- -10^5 <= nums[i] <= 10^5
SysRound wrote this statement. A reference solution checks every example.
Related questions
Continue with questions that share topics or the same question type.
- 3Sum Closest
Coding · Array · Sorting · Two Pointers
- 4Sum
Coding · Array · Sorting · Two Pointers
- Advantage Shuffle
Coding · Array · Greedy · Sorting
- Heaters
Coding · Array · Binary Search · Sorting
Sources · 2 references
These records explain where the question appears. A company tag or candidate report does not guarantee a future interview question.
Hello Interview · 3 records
Meta
Leetcode 15. 3Sum
Reported Nov 6, 2024 · 1 source report
MID_LEVEL
Source snapshot: Nov 12, 2026
View sourceStripe
Leetcode 15. 3Sum
Reported Jan 24, 2026 · 1 source report
INTERN
Source snapshot: Nov 12, 2026
View sourceVisa
Leetcode 15. 3Sum
Reported Sep 18, 2026 · 1 source report
STAFF
Source snapshot: Nov 12, 2026
View source
LeetCode company tags · 16 records
Amazon
3Sum
Reported date not specified · Source window: 3mo
Source snapshot: Oct 20, 2026