Problem · Array
Problem statement
Given an integer array nums, return every unique triplet [a, b, c] whose values sum to 0.
Output Rules
- Sort each triplet in ascending order.
- Sort the list of triplets lexicographically.
- Do not return duplicate triplets.
Function
threeSum(nums: int[]) → int[][]Examples
Example 1
nums = [-1,0,1,2,-1,-4]return = [[-1,-1,2],[-1,0,1]]Example 2
nums = [0,0,0,0]return = [[0,0,0]]The same value triplet is returned only once.
More Agoda problems
- Minimum Absolute Difference PairsONSITE INTERVIEW · Seen Jun 2026
- Feasibility of Printing Within Given DaysONSITE INTERVIEW · Seen May 2026
- Minimum Daily Printing LimitONSITE INTERVIEW · Seen May 2026
- Count One Groups by SizeOA · Seen Jul 2025
- Minimum Price With Discount CouponsOA · Seen Jul 2025
- Lexicographically Smallest Task QueueOA · Seen Jul 2025
- Team FormationSeen Apr 2025
- Two-Core Process AssignmentSeen Apr 2025