Generate Pattern Matching Strings (Early Career :)
Updated
Problem statement
You are given a pattern consisting of alpha characters and [] (square brackets).
Anything outside of [] is literal, anything inside [] are alternatives
(pick exactly one). Return all strings from a list of strings that match a given pattern. The
pattern changes for every call, the list of strings stays the same and can be preprocessed.
Function
generatePatternMatchingStrings(pattern: String, strings: List<String>) → List<String>Examples
Example 1
pattern = "tele[op]ho[bnm]e"strings = ["cat", "dog", "telephone", "telephonepole", "tele", "telehoe", "teleophobme"]return = ["telephone"]:O
Constraints
1 ≤ pattern.length ≤ 10^50 ≤ strings.length ≤ 10^5- The total length of all strings is at most
10^6. - The pattern contains alphabetic literals and well-formed, non-empty square-bracket groups. Each bracket group contributes exactly one character to a match.
- Return matching strings in their original input order.
More Google Phone Screen questions
- Evaluate a Nested Math ExpressionPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Route Pattern MatcherPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Best Stock Trade with Buy and Sell DaysPHONE SCREEN · Seen Nov 2026
- Word Chain Jumps in a GridPHONE SCREEN · Seen Nov 2026
- Dice-Walk Winning ProbabilityPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Lowest Common Ancestor in an N-ary TreePHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Apartment Housemate PreferencesPHONE SCREEN · Seen Nov 2026
- Price at Query TimestampsPHONE SCREEN · Seen Nov 2026
- Course Schedule Cycle DetectionPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Logger Rate Limiter with Every-Arrival HistoryPHONE SCREEN · Seen Nov 2026
Similar questions at other companies
- Indexed API Field Pattern QueriesStripe · PHONE SCREENStripe interview questions
- Transform Dotted Keys into a Nested MapProofpoint · ONSITE INTERVIEW
- Evaluate an Arithmetic Expression Written in WordsBrex · PHONE SCREEN
- Top K Movies by Play Count from CSV DataTubi · PHONE SCREEN
- Remove Parentheses from a Plus-Minus ExpressionOracle · PHONE SCREENOracle interview questions
- Parse Nested Message TypesApplied Intuition · PHONE SCREENApplied Intuition interview questions
- Most Frequent Call Path From Function Trace LogsRoblox · PHONE SCREENRoblox interview questions
- Decode StringCompass International Holdings · PHONE SCREENCompass International Holdings interview questions
- Valid Number with ExponentsLinkedIn · PHONE SCREENLinkedIn interview questions
- Rich Text Parser Part 3 (Depth Tokens)Figma · PHONE SCREEN · ONSITE INTERVIEWFigma interview questions