#C930. Dictionary Word Lookup
Dictionary Word Lookup
Dictionary Word Lookup
You are given a dictionary string and a lookup word. Your task is to determine whether the lookup word exists in the dictionary string after removing any leading or trailing punctuation and normalizing all letters to lowercase. In other words, if we define a word as a contiguous sequence of alphanumeric characters (matching the regex pattern \(\texttt{\textbackslash\b\textbackslash\w+\textbackslash\b}\)), you need to output YES
if the lookup word appears in the processed dictionary string, and NO
otherwise.
Note: The punctuation is only removed from the beginning and end of each word. The matching should be case-insensitive. For example, the word "Dictionary
" in the input should match "dictionary
" in the lookup word.
inputFormat
The input is provided via standard input (stdin) and consists of two lines:
- The first line contains the dictionary string.
- The second line contains the lookup word.
outputFormat
Output a single line to standard output (stdout): YES
if the lookup word exists in the dictionary string after processing, or NO
otherwise.
hello, world. This is a simple dictionary containing: several words!
dictionary
YES