Problem 3298 · Hard

Count Substrings That Can Be Rearranged to Contain a String II

Use one sliding window that grows until it covers word2, then count every end from there to the string end.

Open the interactive visualisation