#K73387. Keyword Search in a String
Keyword Search in a String
Keyword Search in a String
Given a string ( s ) of length ( n ) and a list of ( m ) keywords, determine whether at least one keyword appears as a substring within ( s ). A substring is defined as a contiguous sequence of characters within ( s ); mathematically, a string ( k ) is a substring of ( s ) if there exists an index ( i ) such that ( s[i:i+|k|] = k ).
For example, if ( s = \texttt{hellohoware} ) and the keywords are ["hello", "are", "what"], the answer is "YES" because ( s ) contains both "hello" and "are" as substrings. If none of the keywords appear in ( s ), print "NO".
inputFormat
Input is given via standard input (stdin). The first line contains an integer ( n ) denoting the length of string ( s ). The second line contains the string ( s ). The third line contains an integer ( m ) representing the number of keywords. This is followed by ( m ) lines, each containing one keyword.
outputFormat
Output via standard output (stdout) a single line: "YES" if at least one keyword is a substring of ( s ), or "NO" otherwise.## sample
10
hellohoware
3
hello
are
what
YES
</p>