#C343. Check Ordered Subsequence in Text

    ID: 46856 Type: Default 1000ms 256MiB

Check Ordered Subsequence in Text

Check Ordered Subsequence in Text

You are given an integer (n), a sequence of (n) words, and a text string. Your task is to determine if the text contains all the given words in the same order as they appear in the word sequence (they do not need to be consecutive).

For example, if (n = 3) and the words are "apple banana kiwi", the text "i like to eat apple and then some banana and finally a kiwi" should output "YES", whereas a text that does not contain the words in order should output "NO".

inputFormat

The input is taken from (stdin) and consists of three lines:

  1. An integer (n), representing the number of words.
  2. A line with (n) space-separated words.
  3. A line with the text in which to search for these words.

outputFormat

Output to (stdout) a single line containing "YES" if the text contains all the words in the given order, otherwise output "NO".## sample

3
apple banana kiwi
i like to eat apple and then some banana and finally a kiwi
YES