#3455
Shortest Matching Substring
hard · 23.9% accepted · 46 likes · top 3%
two pointers · string · binary search · string matching
Description
You are given a string s and a pattern string p, where p contains exactly two '*' characters.
The '*' in p matches any sequence of zero or more characters.
Return the length of the shortest substring in s that matches p. If there is no such substring, return -1.
Note: The empty substring is considered valid.
Solution