IP to CIDR / Validate IP Ranges

Problem

Given a start IP and a number of IPs to cover, return the minimal list of CIDR blocks that exactly covers the range; or, given IP ranges, determine whether they fit a CIDR.

Example

ip="255.0.0.7", n=10 -> ["255.0.0.7/32","255.0.0.8/29","255.0.0.16/32"]

Constraints

  • Handle 32-bit IPv4 arithmetic and bit alignment
added …
LeaderboardSalaryAccount