#3297
Count Substrings That Can Be Rearranged to Contain a String I
medium · 42.7% accepted · 123 likes · top 24%
hash table · string · sliding window
Description
You are given two strings word1 and word2.
A string x is called valid if x can be rearranged to have word2 as a prefix.
Return the total number of valid substrings of word1.
Solution