Amazon Latest Hard OA Problem

Revision en1, by acash, 2024-08-23 14:12:03

the developres at amazon are developing a regex matching libraary for their nlp use cases. a prototype regex matching has the following requirments:

the regex expression contains lowecase english letters, '(', ')' , '.' and '*'.

'.' matches with exactly one lower case english letter

a regular expression followed by '*' matches with zero or more occurences of the regular expression

if an expression is enclosed in parentheses '(' and ')' it is treated as one expression and any asterisk '*' applies to the whole expression

for example regex " (ab)*d "matches with string "d" , "ababd", "abd", but not with "abbd"

given an array arr of length kcontaining strings consisting of lower case english letters only and a string regex of length n , for each of them find whether the given regex matches the string or not and report an array of strings "YES" or "NO" RESPECTIVELY

This question is quite frequently appearing in recent amazon oa observed from leetcode discuss sections. There is similar question on leetcode wildcard matchig but in this we have quotes also () which makes it more tougher any help would be much appreciated on it Thanks.

Tags amazon, recursive, dp

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English acash 2024-08-23 14:12:03 1195 Initial revision (published)