Wildcard Character Array Match
Updated
Problem statement
Given pattern and target, determine whether the pattern array can represent the target string.
Each pattern entry is either a one-character string that must match the target at the same index, or the empty string, which is a wildcard matching any one lowercase English letter. The lengths must be equal.
Function
matchesWildcardArray(pattern: String[], target: String) → booleanExamples
Example 1
pattern = ["a","","c"]target = "abc"return = trueThe empty middle entry matches b.
Example 2
pattern = ["a","b"]target = "ac"return = falseThe literal b does not match target character c.
Example 3
pattern = []target = ""return = trueTwo empty sequences match.
Constraints
0 <= pattern.length,target.length <= 200000.- Each pattern entry is empty or one lowercase English letter.
targetcontains 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
- Batched Subsequence Word MatchesONSITE INTERVIEW · Seen Nov 2026
Similar questions at other companies
- Bounded Word Guess SolverAtlassian · ONSITE INTERVIEW
- Retry with an Attempt LimitOracle · ONSITE INTERVIEW
- Extract Error Log ContextFlexTrade · ONSITE INTERVIEW
- BitFont - Render a Kerned PairStripe · ONSITE INTERVIEW
- Print Vertical Asterisk BarsMicrosoft · ONSITE INTERVIEW
- Add Two Numbers Given as Digit ArraysCapital One · ONSITE INTERVIEW
- Query Log MatchDatadog · PHONE SCREEN · ONSITE INTERVIEW
- Compress Editor Actions into Operational Transform OperationsReplit · OA · PHONE SCREEN · ONSITE INTERVIEW
- Trace Events from Stable Whole-Stack StatesAnthropic · ONSITE INTERVIEW
- Hex Dump FormatterWaymo · ONSITE INTERVIEW