Algorithm · C3.ai · Hard
You are given two strings: a source string and a pattern string. Your task is to locate the shortest contiguous substring of the source in which every character of the pattern appears. Repeated characters count: if a character occurs several times in the pattern, the chosen substring must include that character at least as many times as the pattern does. If no substring of the source satisfies this requirement, return the empty string. Examples Example 1 Example 2