#3455

Shortest Matching Substring

international master · 2130 · lc hard +32 · 23.9% accepted · 46 likes · top 3%

Description

Given strings s and p, where p has exactly two wildcard \'*\' characters (each matching any sequence of zero or more characters), determine the shortest substring of s that satisfies the pattern.

Return the length of that shortest matching substring, or -1 if no match exists.

Note: An empty substring is a valid match.

Code

1
2
3