Tap here to switch tabs
Problem
Submissions

Problem: Shortest Matching Substring

Shortest Matching Substring asks you to find the shortest substring of a given string that matches a pattern containing exactly two wildcards, each matching any sequence of characters, or report no match.

Statement

You are given a string s and a pattern string p, where p contains lowercase English letters and exactly two wildcard characters '*'.

A wildcard character '*' can match any sequence of zero or more characters.

Return the minimum length of a substring of s that matches the pattern p. If no such substring exists, return −1-1.

Constraints:

  • 1≤1 \leq s.length ≤105\leq 10^5

  • 2≤2 \leq p.length ≤105\leq 10^5

  • s contains only lowercase English letters.

  • p contains only lowercase English letters and exactly two '*'.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Shortest Matching Substring

Shortest Matching Substring asks you to find the shortest substring of a given string that matches a pattern containing exactly two wildcards, each matching any sequence of characters, or report no match.

Statement

You are given a string s and a pattern string p, where p contains lowercase English letters and exactly two wildcard characters '*'.

A wildcard character '*' can match any sequence of zero or more characters.

Return the minimum length of a substring of s that matches the pattern p. If no such substring exists, return −1-1.

Constraints:

  • 1≤1 \leq s.length ≤105\leq 10^5

  • 2≤2 \leq p.length ≤105\leq 10^5

  • s contains only lowercase English letters.

  • p contains only lowercase English letters and exactly two '*'.