FastPrepBatched Subsequence Word Matches
Problems/Batched Subsequence Word Matches

Batched Subsequence Word Matches

Google logoGoogle● MediumNEW GRADFULLTIMEONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The report asks for the possible word matches for a swipe string. It says a match means a subsequence, not a substring. The reported solution uses a position map plus binary search. We fixed the output order, how duplicates are handled, that input is lowercase, and how empty strings are handled. Our version is about 93% the same as the reported question.

Given a lowercase swipe string swipe and an array words, return every word that is a subsequence of swipe.

A subsequence keeps character order but may skip characters. Preserve input order and repeated word occurrences. The empty word is a subsequence of every string.

Function

matchingSubsequenceWords(swipe: String, words: String[]) → String[]

Examples

Example 1

swipe = "abcde"words = ["ace","aec","bd"]return = ["ace","bd"]

ace and bd preserve their character order in the swipe string, while aec does not.

Example 2

swipe = "aabbcc"words = ["abc","aac","acb","abc"]return = ["abc","aac","abc"]

Both occurrences of abc are preserved. acb reverses the final two required positions.

Example 3

swipe = ""words = ["","a"]return = [""]

Only the empty word is a subsequence of the empty swipe string.

Constraints

  • 0 <= swipe.length <= 200000.
  • 0 <= words.length <= 100000.
  • The total length of all words is at most 1000000.
  • All strings contain only lowercase English letters.

More Google Onsite Interview questions

  • Route Pattern MatcherPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Evaluate a Nested Math ExpressionPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Distinct Subset SumsONSITE INTERVIEW · Seen Nov 2026
  • Playlist With No Same Artist in a RowONSITE INTERVIEW · Seen Nov 2026
  • Delete Nodes and Return Forest RootsONSITE INTERVIEW · Seen Nov 2026
  • Dice-Walk Winning ProbabilityPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • First and Last Target Position in a Mountain ArrayONSITE INTERVIEW · Seen Nov 2026
  • Lowest Common Ancestor in an N-ary TreePHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • 0/1 Knapsack with Weight and Volume LimitsONSITE INTERVIEW · Seen Nov 2026
  • Course Schedule Cycle DetectionPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026

Similar questions at other companies

  • Time Based Key-Value StoreZillow · PHONE SCREEN
  • Classify Password StrengthHackerRank · OA · PHONE SCREEN · ONSITE INTERVIEW
  • Highest Bid Campaign MatcherStackAdapt · ONSITE INTERVIEW
  • Group AnagramsAmazon Web Services · ONSITE INTERVIEW
  • Query Log MatchDatadog · PHONE SCREEN · ONSITE INTERVIEW
  • File System Shell CommandsHarvey · ONSITE INTERVIEW
  • Invoice / Payment ReconciliationStripe · PHONE SCREEN · ONSITE INTERVIEW
  • Most Frequent Call Path From Function Trace LogsRoblox · PHONE SCREEN · ONSITE INTERVIEW
  • Shortest Uncommon SubstringAirbnb · ONSITE INTERVIEW
  • Feature Flags with Rules, Dependencies and ExposurePerplexity AI · ONSITE INTERVIEW
See Google hiring insights
Saved
class Solution {
    public String[] matchingSubsequenceWords(String swipe, String[] words) {
        // Write your code here.
    }
}
Checking account…