FastPrepSubsets
Problems/Subsets

Subsets

Google logoGoogle● MediumINTERNONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: A firsthand Google SWE intern report in the 2026 recruiting cycle names Subsets as a technical-round problem. We added a binary-mask output order so results are always the same. Our version is about 95% the same as the reported question.

Given an integer array nums whose elements are unique, return all of its subsets, including the empty subset.

Within each subset, preserve the elements' original input order. Return the subsets in increasing binary-mask order: bit i indicates whether nums[i] belongs to that subset.

Function

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

Examples

Example 1

nums = [1,2,3]return = [[],[1],[2],[1,2],[3],[1,3],[2,3],[1,2,3]]

The eight outputs correspond to masks 000 through 111.

Example 2

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

A one-element array has the empty subset and the subset containing that element.

Constraints

  • 1 <= nums.length <= 10.
  • -10 <= nums[i] <= 10.
  • All values in nums are unique.

More Google Onsite Interview questions

  • Route Pattern MatcherPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Evaluate a Nested Math ExpressionPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Distinct Subset SumsONSITE INTERVIEW · Seen Nov 2026
  • Playlist With No Same Artist in a RowONSITE INTERVIEW · Seen Nov 2026
  • Delete Nodes and Return Forest RootsONSITE INTERVIEW · Seen Nov 2026
  • Dice-Walk Winning ProbabilityPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • First and Last Target Position in a Mountain ArrayONSITE INTERVIEW · Seen Nov 2026
  • Lowest Common Ancestor in an N-ary TreePHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • 0/1 Knapsack with Weight and Volume LimitsONSITE INTERVIEW · Seen Nov 2026
  • Batched Subsequence Word MatchesONSITE INTERVIEW · Seen Nov 2026

Similar questions at other companies

  • Maximum Unique-Character Word SubsetMeta · ONSITE INTERVIEWMeta interview questions
  • SubsetsBloomberg LP · PHONE SCREEN · ONSITE INTERVIEWBloomberg LP interview questions
  • Optimal Account BalancingAmazon · ONSITE INTERVIEW
  • SubsetsTemu · PHONE SCREENTemu interview questions
  • Count Legal Outfit CombinationsDuolingo · OADuolingo interview questions
  • Generate All Permutations of a NumberFleetx · ONSITE INTERVIEW
  • Find the Two Unique NumbersZomato / Eternal · ONSITE INTERVIEWZomato / Eternal interview questions
  • Unique Single-Use Sum CombinationsLinkedIn · ONSITE INTERVIEWLinkedIn interview questions
  • Bounded Combination Sum with Signed CandidatesConfluent · ONSITE INTERVIEWConfluent interview questions
  • Spaceship Equipment LoadoutJane Street · ONSITE INTERVIEWJane Street interview questions

Interview reports that mention this question

  • Google SWE Intern Onsite Questions: 16 Experiences (Part 2 of 3)

Google interview experiences

  • Google interviews · November 2026
  • Google Software Engineer Onsite Questions: 10 Experiences
  • Google OA: What It Tests (2026)
  • Google L4 SWE Phone Screen: 1 Experience
  • Google ML Engineering Manager Onsite: 1 Experience
All Google interview questionsSee Google hiring insights
Saved
class Solution {
    public List<List<Integer>> subsets(int[] nums) {
        // Write your code here.
    }
}
Checking account…