Count Distinct Fixed-Length Substrings
Updated
Problem statement
Given a lowercase string text and an integer k, consider every contiguous substring of text whose length is exactly k.
Return the number of distinct substring values among those windows. Equal text appearing at different positions counts once.
Function
countDistinctSubstrings(text: String, k: int) → intExamples
Example 1
text = "ababa"k = 2return = 2The length-2 windows are ab, ba, ab, and ba. The distinct values are ab and ba.
Example 2
text = "aaaa"k = 2return = 1Every length-2 window is aa, so there is one distinct value.
Example 3
text = "abc"k = 1return = 3The one-character windows are a, b, and c, all distinct.
Constraints
1 <= text.length <= 10^5.textcontains only lowercase English letters.1 <= k <= text.length.
Source note: These two source-faithful panels preserve the complete March 12 Adobe OA task and its set-based solution notes.
More Adobe Online Assessment questions
- Base Unit ConversionsOA · Seen Nov 2026
- Rotate an Array In PlaceOA · PHONE SCREEN · Seen Aug 2026
- Top-Funded Villages and ProjectsOA · Seen Aug 2026
- Count Parent Nodes With a Target SumOA · Seen Aug 2026
- Largest Binary Number by ConcatenationOA · Seen Aug 2026
- Count Events by CategoryOA · Seen Aug 2026
- Graph M-ColoringOA · Seen Aug 2026
- Hall of Shifting TilesOA · Seen Aug 2026
- K-th Ancestor Subtree Preorder QueryOA · Seen Aug 2026
- Maze ReachabilityOA · Seen Aug 2026
Similar questions at other companies
- Perfect SubstringAXQ Capital · OA
- Maximum Valid Substring FrequencyMicrosoft · OAMicrosoft interview questions
- Longest Distinct StringSuperhuman · OASuperhuman interview questions
- Longest Substring Without Repeating CharactersAkuna Capital · OAAkuna Capital interview questions
- Perfect SubstringsVisa · OAVisa interview questions
- Vowel SubstringSnowflake · OASnowflake interview questions
- Video ID Generation (Generic)TikTok · OATikTok interview questions
- Unaligned DedupeRubrik · OARubrik interview questions
- Get Max OccurrencesIBM · OAIBM interview questions
- Find P-Matching ScoreAmazon · OA
Adobe interview experiences
- Adobe New Grad OA: Unit Conversion and Code Review: 1 Experience
- 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)