<strong>Explanation:</strong> There are 11 valid substrings in word: "c", "b", "a", "ba", "aa", "bc", "baa", "aab", "ab", "abc" and "aabc". The length of the longest valid substring is 4.
It can be shown that all other substrings contain either "aaa" or "cb" as a substring. </pre>
<p><strongclass="example">Example 2:</strong></p>
<pre>
<strong>Input:</strong> word = "leetcode", forbidden = ["de","le","e"]
<strong>Output:</strong> 4
<strong>Explanation:</strong> There are 11 valid substrings in word: "l", "t", "c", "o", "d", "tc", "co", "od", "tco", "cod", and "tcod". The length of the longest valid substring is 4.
It can be shown that all other substrings contain either "de", "le", or "e" as a substring.