3298. Count Substrings That Can Be Rearranged to Contain a String II
You are given two strings
word1andword2.A string
xis called valid ifxcan be rearranged to haveword2as 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.