Missing Words
Problem statement
You are given two sentences s and t. Each sentence contains words separated by single spaces, with no leading or trailing space. The words of t form a case-sensitive subsequence of the words of s: they appear in the same order, but they do not need to be adjacent.
Return the words of s that are missing from t, preserving their original order.
Function
missingWords(s: String, t: String) → List<String>Examples
Example 1
s = "I am using HackerRank to improve programming"t = "am HackerRank to improve"return = ["I", "using", "programming"]Matching the four words of t leaves I, using, and programming unmatched in s.
Example 2
s = "I love programming"t = "I love programming"return = []Every word is matched, so no words are missing.
Example 3
s = "one two one three"t = "one one"return = ["two", "three"]The two occurrences of one must be matched in order, leaving the intervening and trailing words.
Constraints
1 <= t.length() <= s.length() <= 10^6.- Both strings contain only English letters and single spaces between words.
- Every word has length from 1 through 15.
- The words of
tare guaranteed to be a subsequence of the words ofs. - Matching is case-sensitive.