3297. Count Substrings That Can Be Rearranged to Contain a String I
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. Example 1: Input: word1 = "bcca", word2 = "abc" Output: 1 Explanation: The only valid substring is "bcca" which can be rearranged to "abcc" having "abc" as a prefix. Example 2: Input: word1 = "abcabc", word2 = "abc"
HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17
CodeSearch Tutor
Hints, not spoilers — it won’t hand over the full solution unless you insist.
Sign in to chat with the tutor and save your progress.
Sign in to start