You are given:
"192.168.1.5"
.
"a.b.c.d/x"
, where
0 <= a,b,c,d <= 255
and
0 <= x <= 32
.
Each CIDR block a.b.c.d/x represents all IP addresses whose first x bits are identical to the first x bits of the base address a.b.c.d.
Task:
Return the first CIDR block in the given list that covers (contains) the given IP address. If none of the CIDR blocks contains the IP, return some designated value such as null or an empty string.
Clarifications:
Define clearly what you return when there is no matching CIDR.