Question Details
There are n blacklisted IP regexes given as an array of strings. It consists of * or \'.\' e.g. .123. matches with "12.1.123.45", "1.123.435.12", but not with "1.2.3.4". There are...
Full Details
There are n blacklisted IP regexes given as an array of strings.
It consists of * or \'.\' e.g. .123. matches with "12.1.123.45", "1.123.435.12",
but not with "1.2.3.4". There are \'q\' IP requests to be processed given as
an array of IP addresses. A request is blocked if it matches with any blacklisted regex
IP or IP address that has sent at least 2 requests in the last 5 seconds. Which is not blocked,
return 1 if it will be blocked else 0
e.g. blacklist =["111." , "123." , "34."] q = 7
requests = ["123.1.23.34", "121.1.23.34", "121.1.23.34", "34.1.23.34","121.1.23.34", "12.1.23.34", "121.1.23.34"]
output: [1,0,0,1,1,0,0]
How to approach this problem?
About This Question
This is a reported interview question from a microsoft interview for a swe role during the oa round reported in 2024.