#C2030. Clip Sequence Excluding Banned Words
Clip Sequence Excluding Banned Words
Clip Sequence Excluding Banned Words
You are given a sequence of M words and a list of N banned words. Your task is to extract all the words from the sequence that do not appear in the banned list and print them in their original order, separated by a single space.
Let the sequence be \(S = [w_1, w_2, \dots, w_M]\) and the banned set be \(B = \{b_1, b_2, \dots, b_N\}\). The answer should be a string formed by concatenating all words \(w_i\) such that \(w_i \notin B\), preserving their order from the input.
Examples:
- If
M = 7
,N = 2
,sequence = ["the", "quick", "brown", "fox", "jumps", "over", "the"]
andbanned = ["fox", "the"]
, then the output should bequick brown jumps over
. - If
M = 4
,N = 4
,sequence = ["a", "b", "c", "d"]
andbanned = ["a", "b", "c", "d"]
, then the output should be an empty string.
Input/Output Format:
The input is provided via stdin and the output should be printed to stdout.
inputFormat
The first line contains two integers \(M\) and \(N\): the number of words in the sequence and the number of banned words, respectively.
The second line contains \(M\) words separated by spaces representing the sequence.
The third line contains \(N\) banned words separated by spaces. If \(N = 0\), this line will be empty.
outputFormat
Output a single line that contains the filtered words from the sequence (i.e., words not in the banned list), concatenated in their original order separated by a single space. If none, output an empty line.
## sample7 2
the quick brown fox jumps over the
fox the
quick brown jumps over