All Longest Substrings Without Repeating Characters
Updated
Problem statement
Given a string s, return every occurrence of a longest substring with no repeated character. A substring is a run of characters that sit next to each other in s.
List the occurrences from left to right. If the same text appears at several longest positions, include it once for each position. If s is empty, return an empty array.
Function
allLongestUniqueSubstrings(s: String) → String[]Examples
Example 1
s = "abcabcbb"return = ["abc","bca","cab","abc"]The longest length with no repeat is three. Four substrings reach it, and the text abc appears at two positions, so it is listed twice.
Example 2
s = "bbbbb"return = ["b","b","b","b","b"]Every substring longer than one character repeats b, so each single character is returned, once per position.
Example 3
s = ""return = []The string is empty, so the answer is an empty array.
Constraints
0 <= s.length <= 100000.scontains ASCII English letters, digits, spaces, and common symbols.- Each returned string is copied exactly from
s, character for character.
More Bloomberg LP Phone Screen questions
- Pascal's TrianglePHONE SCREEN · ONSITE INTERVIEW · Seen Dec 2026
- Valid Triangle NumberPHONE SCREEN · ONSITE INTERVIEW · Seen Dec 2026
- Collatz Conjecture with Shared MemoizationPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Word SearchOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- N-ary Index-Path Encoder and DecoderPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Trapping Rain WaterPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Fewest Coins CombinationPHONE SCREEN · Seen Nov 2026
- Recommend Films from Viewers Who Watched Everything You DidPHONE SCREEN · Seen Nov 2026
- Track New Values in Sorted OrderPHONE SCREEN · Seen Nov 2026
- Design Browser HistoryPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
Similar questions at other companies
- Longest Substring Without Repeating CharactersAngel One · PHONE SCREEN
- Longest Substring Without Repeating CharactersNykaa · PHONE SCREENNykaa interview questions
- Longest Substring Without Repeating CharactersIBM · PHONE SCREENIBM interview questions
- Longest Substring Without Repeating CharactersTikTok · PHONE SCREENTikTok interview questions
- Find Word-Multiset WindowsAmazon · PHONE SCREEN
- Find the First Contiguous HaikuFaire · PHONE SCREEN
- Longest Substring Without Repeating CharactersCapgemini · PHONE SCREENCapgemini interview questions
- Longest Substring Without Repeating CharactersWex · PHONE SCREEN
- Minimum Window of Required WordsSalesforce · PHONE SCREENSalesforce interview questions
- Longest Substring Without Repeating CharactersRedNote · PHONE SCREEN