Given an IP address and arrays of blocked IP addresses, blocked prefixes and blocked ports, return whether the provided IP address is allowed (works) or not.
Asked in the Technical round (HackerRank coding) stage. Coded live in C++ on HackerRank while screen sharing.
Implement is_allowed(ip_address, blocked_ips, blocked_prefixes, blocked_ports, port) for IPv4 addresses. Return False if the IP exactly matches a blocked IP, belongs to any blocked CIDR prefix, or the port is blocked. Otherwise return True.
ip_address: string, blocked_ips: array of strings, blocked_prefixes: array of CIDR strings, blocked_ports: array of integers, port: integer.def is_allowed(ip_address, blocked_ips, blocked_prefixes, blocked_ports, port):