FastPrepSorted Subsets of a String
Problems/Sorted Subsets of a String

Sorted Subsets of a String

Microsoft logoMicrosoft● MediumFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a Microsoft phone screen. The original report leaves out how to handle repeated characters and the exact order. Our version is about 92% the same as the reported question.

You are given a string s made of distinct lowercase English letters. Return every subset of its characters.

Write each subset as a string with its letters in ascending order. The empty subset counts too, written as the empty string. Return the full list in lexicographic (dictionary) order.

Function

generateSubsets(s: String) → String[]

Examples

Example 1

s = "abc"return = ["","a","ab","abc","ac","b","bc","c"]

The string abc has eight subsets, counting the empty one. Each subset keeps its letters in order, so you write ab, never ba. The list is in lexicographic order, so ab and abc come before ac.

Example 2

s = "ba"return = ["","a","ab","b"]

The order of the input letters does not matter. Each subset is still written with its letters sorted, so the two-letter subset is ab. The list is sorted the same way as for any other input.

Example 3

s = ""return = [""]

The empty string has exactly one subset: the empty subset.

Constraints

  • 0 <= s.length <= 16
  • s contains distinct lowercase English letters.

More Microsoft Phone Screen questions

  • Config Store with Priority OverridesPHONE SCREEN · Seen Nov 2026
  • Corporation Reporting LinesPHONE SCREEN · Seen Oct 2026
  • Random Forest Classifier from ScratchPHONE SCREEN · Seen Oct 2026
  • Least Recently Used CacheOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Greedy and Beam Sentence DecodingPHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026
  • Top K Frequent ElementsPHONE SCREEN · Seen Sep 2026
  • 3SumPHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026
  • Arithmetic Expression EvaluatorPHONE SCREEN · Seen Sep 2026
  • Employee Hierarchy Cycle and Depth AnalysisPHONE SCREEN · Seen Sep 2026
  • Most Visited String SectorsPHONE SCREEN · Seen Sep 2026

Similar questions at other companies

  • String Permutations in Custom Character OrderWex · OA · PHONE SCREEN
  • Permutations IILinkedIn · PHONE SCREENLinkedIn interview questions
  • Unique String PermutationsAmazon · PHONE SCREEN
  • Generate All String PermutationsBloomberg LP · PHONE SCREENBloomberg LP interview questions
  • Generate Strings of Length at Least ThreeMorgan Stanley · ONSITE INTERVIEWMorgan Stanley interview questions
  • Rank Word-Translation Hints from Sentence TranslationsDuolingo · PHONE SCREEN · ONSITE INTERVIEWDuolingo interview questions
  • In-Memory Filesystem CommandsPerplexity AI · PHONE SCREEN · ONSITE INTERVIEWPerplexity AI interview questions
  • Largest Number Below N from Reusable DigitsByteDance · PHONE SCREENByteDance interview questions
  • Merge Weekday and Time IntervalsNextdoor · PHONE SCREENNextdoor interview questions
  • Top K Movies by Play Count from CSV DataTubi · PHONE SCREEN

Microsoft interview experiences

  • Microsoft OA Questions, October 2026: 4 Experiences
  • Microsoft Experienced SWE Phone Screen: 1 Experience
  • Microsoft Explore and Student SWE: 12 Experiences (Part 6 of 6)
  • Microsoft SWE Intern, Early 2025: 41 Experiences (Part 5 of 6)
  • Microsoft SWE Intern, Mid 2025: 42 Experiences (Part 4 of 6)
  • Microsoft SWE Intern, Late 2025: 47 Experiences (Part 3 of 6)
All Microsoft interview questionsSee Microsoft hiring insights
Saved
class Solution {
    public String[] generateSubsets(String s) {
        // Write your solution here
    }
}
Checking account…