3298. Count Substrings That Can Be Rearranged to Contain a String II
You are given two strings
word1
andword2
.A string
x
is called valid ifx
can be rearranged to haveword2
as a prefix.Return the total number of valid substrings of
word1
.Note that the memory limits in this problem are smaller than usual, so you must implement a solution with a linear runtime complexity.