v of length n (the length of word) with all elements set to n.mp to store the forbidden substrings.i of word:
a. Create a temporary string s.
b. For each index j from i to n and while j-i is less than 10:
i. Append word[j] to s.
ii. If s is in mp, set v[i] to j and break.ans to store the maximum valid substring length and curr to store the current valid substring length.i and j to iterate over word:
a. If v[i] is n, increment curr.
b. Otherwise, find the minimum index idx such that v[j] is less than n and update curr and ans accordingly.
c. Reset curr if a forbidden substring is encountered.ans as the length of the longest valid substring.