All Longest Substrings Without Repeating Characters
Problem statement
Given a string s, return every occurrence of a longest contiguous substring that contains no repeated character.
Return occurrences from left to right. If equal text appears at multiple maximum-length positions, include it once for each position. Return an empty array when s is empty.
Function
allLongestUniqueSubstrings(s: String) → String[]Examples
Example 1
s = "abcabcbb"return = ["abc","bca","cab","abc"]The maximum length is three. Four left-to-right occurrences reach that length; the text abc appears at two different positions and is returned twice.
Example 2
s = "bbbbb"return = ["b","b","b","b","b"]Every one-character occurrence is a longest valid substring.
Example 3
s = ""return = []An empty input has no nonempty substring occurrence.
Constraints
0 <= s.length <= 100000.scontains ASCII English letters, digits, spaces, and common symbols.- The returned occurrence strings preserve their original byte-for-byte text.