Minimum Covering Substring
Updated
Problem statement
Given strings s and t, return the shortest contiguous substring of s that contains every character of t with at least its required multiplicity.
- Character matching is case-sensitive.
- If several covering substrings have minimum length, return the leftmost one.
- Return the empty string when no covering substring exists.
Function
minCoveringSubstring(s: String, t: String) → StringExamples
Example 1
s = "ADOBECODEBANC"t = "ABC"return = "BANC"BANC is the shortest substring containing A, B, and C.
Example 2
s = "aaabcbcba"t = "aabc"return = "aabc"The substring from index 1 through 4 contains two a characters plus b and c; no shorter window can satisfy four required characters.
Constraints
0 <= s.length, t.length <= 100000.sandtcontain case-sensitive ASCII characters.
More ByteDance Onsite Interview questions
- Course SchedulePHONE SCREEN · ONSITE INTERVIEW · Seen Dec 2026
- Largest Rectangle in HistogramPHONE SCREEN · ONSITE INTERVIEW · Seen Dec 2026
- Reverse Linked ListPHONE SCREEN · ONSITE INTERVIEW · Seen Dec 2026
- Search a Row- and Column-Sorted MatrixONSITE INTERVIEW · Seen Nov 2026
- Alien DictionaryPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Lexicographically Smallest Topological OrderPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Implement Multi-Head AttentionPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Dynamic Median with Additions and DeletionsONSITE INTERVIEW · Seen Oct 2026
- Serialize and Deserialize a String Key-Value StoreONSITE INTERVIEW · Seen Oct 2026
- Binary Tree Maximum Path SumONSITE INTERVIEW · Seen Oct 2026
Similar questions at other companies
- Minimum Window SubstringAmazon · PHONE SCREEN · ONSITE INTERVIEW
- Minimum Window SubstringLinkedIn · ONSITE INTERVIEWLinkedIn interview questions
- Minimum Window SubstringMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
- Minimum Window SubstringGoldman Sachs · ONSITE INTERVIEWGoldman Sachs interview questions
- Minimum Window SubstringHighspot · ONSITE INTERVIEW
- Longest Substring with At Most K Distinct CharactersAmazon Web Services · ONSITE INTERVIEWAmazon Web Services interview questions
- Longest Substring Without Repeating CharactersOracle · ONSITE INTERVIEWOracle interview questions
- Longest Substring Without Repeating CharactersSalesforce · ONSITE INTERVIEWSalesforce interview questions
- Longest Substring Without Repeating CharactersGoogle · ONSITE INTERVIEWGoogle interview questions
- Longest Substring Without Repeating CharactersInfosys · ONSITE INTERVIEWInfosys interview questions
ByteDance interview experiences
- ByteDance TikTok USDS SWE Intern Interview: 1 Experience
- ByteDance MLE New Grad Interviews: 1 Experience
- ByteDance Security SRE Intern Phone Screens: 1 Experience
- ByteDance USDS New Grad SWE Phone Screen: 1 Experience
- ByteDance New Grad Data Engineer Video Interviews: 1 Experience
- ByteDance Trust & Safety Research Scientist Intern: 1 Experience