Search
⌘K

Leetcode 751. IP to CIDR

Given a start IPv4 address and a number of consecutive addresses, produce the minimal list of CIDR blocks that exactly cover that range. The key challenge is using 32-bit alignment and powers-of-two block sizes (via bitwise/trailing-zero logic) to greedily choose the largest aligned CIDR at each step.

Asked at:

Databricks


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Late May, 2026

Databricks

Senior

Mid May, 2026

Databricks

Senior

You're implementing a rule-based IPv4 firewall. Given an ordered list of rules (ALLOW or DENY) where each rule is either a single IP or a CIDR block, determine if a target IP should be allowed. Only the first matching rule applies. https://leetcode.com/problems/ip-to-cidr/description/

Early April, 2026

Databricks

Senior

Your account is free and you can post anonymously if you choose.