FastPrepEvery Distinct Substring in Order
Problems/Every Distinct Substring in Order

Every Distinct Substring in Order

Adobe logoAdobe● MediumFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: This problem lists each different substring of a string once, in dictionary order. An entry (a copy of a review) for a technical manager role in India, with an interview on 4 June 2022 and no offer, names four short tasks for the interview call that followed a recruiter's contact. They were a palindrome test, repeated numbers in an array, a CSS strikethrough demo, and this one. For this task the entry has a single line asking for the unique substrings of a string. It gives no input form, output order, limits or examples.

We read unique as different, so each substring is listed once. It could also mean substrings that occur only once, and the editorial covers that as a variant. Our choices: lowercase English letters, 1 to 30 characters, the substrings returned as a list in dictionary order, and new examples.

Our version is about 70% the same as the reported question.

You are given a string s. A substring is a run of one or more consecutive characters of s. Return every different substring of s exactly once: two substrings taken from different positions that spell the same text count as one.

Return them in dictionary order. Compare two strings letter by letter; when one string is the start of the other, the shorter one comes first (so ab comes before abc, which comes before b).

Function

distinctSubstrings(s: String) → List<String>

Examples

Example 1

s = "dad"return = ["a","ad","d","da","dad"]

The pieces of dad are d, a, d, da, ad and dad. d appears twice but is listed once, so 5 different pieces remain, in dictionary order.

Example 2

s = "zzz"return = ["z","zz","zzz"]

Every piece is made of z only, so the different pieces are just the three lengths 1, 2 and 3.

Example 3

s = "pear"return = ["a","ar","e","ea","ear","p","pe","pea","pear","r"]

All four letters differ, so all 4 + 3 + 2 + 1 = 10 pieces are different. In dictionary order a shorter piece comes before a longer piece that starts with it, so e comes before ea.

Constraints

  • 1 <= s.length <= 30
  • s contains only lowercase English letters

More Adobe Phone Screen questions

  • Evaluate a Parenthesized Integer ExpressionPHONE SCREEN · Seen Oct 2026
  • All Elements of Two BSTs in OrderPHONE SCREEN · Seen Aug 2026
  • Rotate an Array In PlaceOA · PHONE SCREEN · Seen Aug 2026
  • Binary Tree Level-Order Traversal by LevelsPHONE SCREEN · ONSITE INTERVIEW · Seen Aug 2026
  • Count Occurrences in a Sorted ArrayPHONE SCREEN · ONSITE INTERVIEW · Seen Jul 2026
  • Count Pairs with Absolute Difference KPHONE SCREEN · Seen Jul 2026
  • Count Subsets with Sum KPHONE SCREEN · Seen Jul 2026
  • Numbers with Exactly Three DivisorsPHONE SCREEN · Seen Jul 2026
  • Sum of Even Nodes on a Path in a Numbered Binary TreePHONE SCREEN · Seen Jul 2026
  • Largest Value in Every Sliding WindowPHONE SCREEN · Seen Jul 2026

Similar questions at other companies

  • Remove Prefix StringsRoblox · PHONE SCREENRoblox interview questions
  • Shell Path AutocompleteFigma · PHONE SCREEN · ONSITE INTERVIEWFigma interview questions
  • Top K Query SuggestionsMicrosoft · PHONE SCREENMicrosoft interview questions
  • Find the Words for Each PrefixDocuSign · PHONE SCREENDocuSign interview questions
  • Find All Word Occurrences in TextSentry · PHONE SCREENSentry interview questions
  • Keyboard Autocomplete SuggestionsLyft · ONSITE INTERVIEWLyft interview questions
  • Transform Dotted Keys into a Nested MapProofpoint · ONSITE INTERVIEW
  • Search Suggestions with a Prefix TreeCitadel · ONSITE INTERVIEWCitadel interview questions
  • Highlight and Rank Overlapping CitationsHarvey · ONSITE INTERVIEWHarvey interview questions
  • Suggested ProductsSquarepoint Capital · OASquarepoint Capital interview questions

Interview reports that mention this question

  • Adobe Frontend and QA Interviews: 14 Experiences (Part 6 of 6)

Adobe interview experiences

  • Adobe Web, QA, DevOps, ML Roles: 13 Experiences (Part 3 of 3)
  • Adobe SWE Interviews, Level Unknown: 25 Experiences (Part 2 of 3)
  • Adobe Interviews, Level Unknown: 38 Experiences (Part 1 of 3)
  • Adobe New Grad MTS Interview Questions: 7 Experiences
  • Adobe ML/Research Intern Interviews: 12 Experiences (Part 4 of 4)
All Adobe interview questionsSee Adobe hiring insights
Saved
class Solution {
    public List<String> distinctSubstrings(String s) {
        // Write your code here.
    }
}
Checking account…