AmazonOA #338
Amazon Review Score
Estimated MediumJudge-ready
Topics (AI-labelled)Two PointersStrings
Find the longest contiguous substring of the review that contains no banned word. Matching ignores case, and a banned word can appear at any position; matching is not limited to whole words. If there is no non-empty valid substring, the answer is 0.
Input
The first line contains review, the second line contains the number of banned words, and each following line contains one banned word. Original bounds: review has length 1..100000 and contains only ASCII uppercase and lowercase letters; there are 1..10 words, each consisting of 1..10 lowercase letters.
Output
Output a single integer, the answer.
Example 1
Input:
GoodProductButScrapAfterWash
2
crap
odpro
Output:
15
Example 2
Input:
Aa
1
a
Output:
0
Example 3
Input:
ExtremeValueForMoney
2
tuper
douche
Output:
20
Example notes
In the first original example, the correct longest fragment is dProductButScra, of length 15; the dProductButScu listed separately by the source is not a fragment of the original string. The answers to the other public examples are 0 and 20.
Editorial
Loading solution…