FastPrep3Sum
Problems/3Sum

3Sum

Agoda logoAgoda● MediumONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: This problem is backed by a real Agoda onsite interview report. The report directly named 3Sum, but it did not include the exact function interface, examples, constraints, or result ordering. The core task match is about 90%.

Given an integer array nums, return every unique triplet of values [a, b, c] whose elements come from three distinct indices and 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[]) → List<List<Integer>>

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.

Constraints

  • 3 <= nums.length <= 3000.
  • -10^5 <= nums[i] <= 10^5.

More Agoda interview questions

  • Sort Ones, Twos, and Threes In PlacePHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Molecular Weight of a Grouped FormulaONSITE INTERVIEW · Seen Oct 2026
  • Minimum Daily Printing LimitONSITE INTERVIEW · Seen Aug 2026
  • Climb Stairs with One, Two, or Three StepsONSITE INTERVIEW · Seen Aug 2026
  • Rank Transform an ArrayONSITE INTERVIEW · Seen Aug 2026
  • Minimum Absolute Difference PairsONSITE INTERVIEW · Seen Jun 2026
  • Feasibility of Printing Within Given DaysONSITE INTERVIEW · Seen May 2026
  • Can Place FlowersPHONE SCREEN · Seen Nov 2026
  • Reverse Words in a StringPHONE SCREEN · Seen Nov 2026
  • Disk Space Window AnalyzerPHONE SCREEN · Seen Sep 2026

Similar questions at other companies

  • Valid Triangle NumberBloomberg LP · PHONE SCREEN · ONSITE INTERVIEWBloomberg LP interview questions
  • Count Winning Dice Face PairsGoogle · PHONE SCREEN · ONSITE INTERVIEWGoogle interview questions
  • Merge Sorted Squares of Two ArraysWhatNot · PHONE SCREEN · ONSITE INTERVIEWWhatNot interview questions
  • 3Sum SmallerSalesforce · ONSITE INTERVIEWSalesforce interview questions
  • Minimum Station Tracks for a Train ScheduleBNSF Railway · ONSITE INTERVIEWBNSF Railway interview questions
  • 4SumAmazon · ONSITE INTERVIEW
  • Sort ColorsCapital One · ONSITE INTERVIEWCapital One interview questions
  • 3SumOptimus Information · ONSITE INTERVIEWOptimus Information interview questions
  • 3SumMicrosoft · PHONE SCREEN · ONSITE INTERVIEWMicrosoft interview questions
  • Next and Previous Lexicographic PermutationAdobe · ONSITE INTERVIEWAdobe interview questions

Agoda interview experiences

  • Agoda Staff Backend OA Questions: 5 Experiences
All Agoda interview questionsSee Agoda hiring insights
Saved
class Solution {
    public List<List<Integer>> threeSum(int[] nums) {
      // write your code here
    }
}
Checking account…