Missing Words

Problem Given an original sentence S and a sentence T that is a subsequence of S's words (same order, some words omitted), return the words of S missing from T, in order.

Input / Output

  • Input: strings S and T (space-separated words).
  • Output: list of missing words in their order of appearance in S.

Constraints

  • Up to 10^5 words; O(|S| + |T|) expected. Duplicate words must be matched by position, not by value.

Example

  • S = "I am practicing daily to improve programming", T = "am daily to improve" → ["I", "practicing", "programming"]
asked …
LeaderboardSalaryAccount