Tap here to switch tabs
Problem
Submissions

Problem: Shortest Matching Substring

med
30 min
Try to solve the Shortest Matching Substring problem.

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

med
30 min
Try to solve the Shortest Matching Substring problem.

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 '*'.