Is Regex Matching
Learn this problemProblem statement
The developers at Amazon are developing a regex matching library for their NLP use cases. A prototype regex matching has the following requirements:
For example,
Given an array, arr, of length k containing strings consisting of lowercase English letters only and a string regex of length n, for each of them find whether the given regex matches with the string or not and report an array of strings "YES" or "NO" respectively.
Function
isRegexMatching(regex: String, arr: String[]) → String[]
Complete the function isRegexMatching in the editor.
isRegexMatching has the following parameters:
- regex: A regex
- arr[k]: An array of strings
Returns
string[]: An array of strings of size k where the ith string is "YES" if the ith string in arr matches with regex, otherwise it is "NO".
🌷༊·°Credit to Alex𓂃🖊
Examples
Example 1
regex = "ab(e.r)*e"arr = ["abbeere", "abefretre"]return = ["NO", "YES"]Example 2
regex = "..()*e*"arr = ["code", "abeee", "cd"]return = ["NO", "YES", "YES"]More Amazon problems
- Secure Maximum DeliveriesOA · Seen Jul 2026
- Find Median from Data StreamONSITE INTERVIEW · Seen Jul 2026
- Handwritten SigmoidPHONE SCREEN · Seen Jul 2026
- Handwritten SoftmaxPHONE SCREEN · Seen Jul 2026
- Koko Eating BananasONSITE INTERVIEW · Seen Jul 2026
- Loyal Customers Across Two DaysONSITE INTERVIEW · Seen Jul 2026
- Maximum System Memory CapacityOA · Seen Jul 2026
- Package Delivery SystemOA · Seen Jul 2026