Problem · String

Generate Pattern Matching Strings (Early Career :)

MediumGoogleNEW GRADPHONE SCREEN
See Google hiring insights

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
drafts saved locally
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