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.
Examples
01 · Example 1
pattern = "tele[op]ho[bnm]e" strings = ["cat", "dog", "telephone", "telephonepole", "tele", "telehoe", "teleophobme"] return = ["telephone"]
:O
More Google problems
- Consolidate On-Call RotationsOA · Seen Jun 2026
- Detonate Bombs with Chain ReactionsONSITE INTERVIEW · Seen May 2026
- Evaluate a Nested Math ExpressionONSITE INTERVIEW · Seen May 2026
- Tic-Tac-Toe Game StatusPHONE SCREEN · Seen May 2026
- Longest Dictionary TokenizationPHONE SCREEN · Seen May 2026
- Minimum Cars for Rental RequestsONSITE INTERVIEW · Seen Apr 2026
- Shortest Path with Mandatory WaypointONSITE INTERVIEW · Seen Apr 2026
- Count Divisible Coin SelectionsOA · Seen Dec 2025
public List<String> generatePatternMatchingStrings(String pattern, List<String> strings) {
// write your code here
}
pattern"tele[op]ho[bnm]e"
strings["cat", "dog", "telephone", "telephonepole", "tele", "telehoe", "teleophobme"]
expected["telephone"]
sign in to submit