Back to problems

Evaluate IP Access Rules

Algorithm · Amazon · Medium

Given a list of IPv4 access-control rules and a target IPv4 address, determine the final access decision: "allow" or "deny". Each rule is represented by a two-item list [action, cidr]. Here action is either "allow" or "deny", and cidr is a CIDR block such as "10.0.0.0/8". The target address is a dotted-quad string such as "10.20.30.40". Use the following resolution semantics: A rule matches when the target IP address falls within its CIDR block. If several rules match, the…

Checking your access…