FastPrep3Sum
Problems/3Sum

3Sum

AT&T logoAT&T● MediumNEW GRADOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in an AT&T new grad online assessment. The report names a variant of a well-known problem, but does not say what the variant changes or give numeric limits. Here you get the well-known 3Sum as a starting point. Our version is about 80% the same as the reported question.

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.

Each returned triplet must be sorted in ascending order. Return the complete list of triplets in lexicographic order, without duplicates.

Function

threeSum(nums: int[]) → List<List<Integer>>

Examples

Example 1

nums = [-1,0,1,2,-1,-4]return = [[-1,-1,2],[-1,0,1]]

The two unique value triplets that sum to 0 are [-1,-1,2] and [-1,0,1].

Example 2

nums = [0,0,0,0]return = [[0,0,0]]

All valid index choices produce the same value triplet, so [0,0,0] appears only once.

Constraints

  • 3 <= nums.length <= 3000.
  • -100000 <= nums[i] <= 100000.

More AT&T Online Assessment questions

  • Companies with Average Salary Above 40000OA · Seen Oct 2026
  • Count Proper Prefix MatchesOA · Seen Oct 2026
  • Minimum Binary Swaps to a PalindromeOA · Seen Oct 2026
  • Break a PalindromeOA · Seen Oct 2025
  • Advertising System Failures ReportOA · Seen Nov 2024
  • Counting Triplets Divisible by DOA · Seen Nov 2024
  • Project EstimatesOA · Seen Nov 2024

Similar questions at other companies

  • Maximum Easy Tasks After RearrangingIBM · OAIBM interview questions
  • Latest Arrival to Catch a BusAutodesk · OAAutodesk interview questions
  • Minimum Removals to Balance ArraySalesforce · OASalesforce interview questions
  • Count Perfect PairsAdyen · OAAdyen interview questions
  • Profitable Project PairsAkuna Capital · OAAkuna Capital interview questions
  • Minimum Height Difference Between Distant PeaksRoblox · OARoblox interview questions
  • Minimum Machines for TasksExpedia · OAExpedia interview questions
  • Find Minimum Possible SizeMathWorks · OAMathWorks interview questions
  • Count Pair Sums in a RangeAdobe · OAAdobe interview questions
  • Catch Fish with Reusable BaitsSusquehanna International Group (SIG) · OASusquehanna International Group (SIG) interview questions

Interview reports that mention this question

  • AT&T TDP Software Engineer Questions: 5 Experiences
All AT&T interview questionsSee AT&T hiring insights
Saved
class Solution {
    public List<List<Integer>> threeSum(int[] nums) {
      // write your code here
    }
}
Checking account…