FastPrepMissing Words
Problems/Missing Words

Missing Words

Vanguard logoVanguard● EasyFULLTIMENEW GRADOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The report does not say which alignment to use for repeated words. This version keeps the earliest matches. Our version is about 95% the same as the reported question. Whether this was an internship is not confirmed.

You are given two sentences, s and t. Sentence t is guaranteed to be a word subsequence of s: its words occur in s in the same order, but they do not need to be consecutive.

Return the words from s that are omitted from t, preserving their order and spelling. Word matching is case-sensitive, and a hyphen is part of a word.

When repeated words allow several possible alignments, match each successive word of t to its earliest available equal word in s after the previous match. Return the words not used by that alignment.

Each sentence contains at least one nonempty word. Consecutive words are separated by one space, with no leading or trailing spaces. If every word is retained, return an empty array.

Function

missingWords(s: String, t: String) → String[]

Examples

Example 1

s = "I like cheese"t = "like"return = ["I","cheese"]

The word like is retained. The words before and after it are omitted, so they appear in that order.

Example 2

s = "a b a"t = "a"return = ["b","a"]

The retained word matches the first a. The remaining words are b and the later a.

Example 3

s = "Build build tools"t = "build"return = ["Build","tools"]

Matching is case-sensitive, so Build is not the retained lowercase word.

Example 4

s = "I am using HackerRank to improve programming"t = "am HackerRank to improve"return = ["I","using","programming"]

The retained words are am, HackerRank, to, and improve. The omitted words are I, using, and programming, in that order.

Constraints

  • 1 <= t.length <= s.length <= 10^6
  • Each word has length from 1 through 15.
  • Words contain only English letters and hyphens. Sentences use single spaces as separators.
  • t is a word subsequence of s.

More Vanguard Online Assessment questions

  • Two SumOA · Seen Sep 2026
  • Valid ParenthesesOA · Seen Sep 2026
  • Are They PangramsOA · Seen Nov 2025
  • Spam DetectionOA · Seen Nov 2025
  • Binge WatchingOA · Seen Jan 2023
  • Minimum Moves Around a Circular ArrayOA · Seen Aug 2022
  • Maximum Occurring CharacterOA · Seen Mar 2022
  • Picking TicketsOA · Seen Mar 2022
  • Tool List: Two Smallest ValuesOA · Seen Nov 2021
  • Group AnagramsOA · Seen Nov 2019

Similar questions at other companies

  • Minimum Swaps to Make PalindromeAmazon · OA
  • Smallest Merge of Two StringsCapital One · OACapital One interview questions
  • Longest Spoken PrefixElevenLabs · ONSITE INTERVIEWElevenLabs interview questions
  • Palindrome After At Most One DeletionAdobe · PHONE SCREENAdobe interview questions
  • Shortest Way to Form a Target StringPinterest · PHONE SCREENPinterest interview questions
  • Wildcard Matching with StarsConfluent · PHONE SCREENConfluent interview questions
  • Text Pattern Matching with StarsHeadlands Technologies · PHONE SCREENHeadlands Technologies interview questions
  • Catch Fish with Reusable BaitsSusquehanna International Group (SIG) · OASusquehanna International Group (SIG) interview questions
  • Maximum Ones After K OperationsGoldman Sachs · OAGoldman Sachs interview questions
  • Minimum Operations to Reduce a Transaction LedgerVisa · OAVisa interview questions

Interview reports that mention this question

  • Vanguard Tech and Risk Older OAs: 12 Experiences (Part 3 of 3)
  • Vanguard Software Older Rounds: 13 Experiences (Part 2 of 3)
  • Vanguard Tech Intern Interviews: 37 Experiences (Part 1 of 3)
All Vanguard interview questionsSee Vanguard hiring insights
Saved
class Solution {
    public String[] missingWords(String s, String t) {
        // Write your code here.
    }
}
Checking account…