Skip to main content
Intermediatecoding Verified

Implement a check that tells whether an IP address belongs to a CIDR range (for example 10.1.0.0/16), and how you would test it.

ReportedSource: interviewing.io: Databricks interview questions guide

Quick answerFree

Parse IPv4 to a 32-bit int, build a mask from the prefix length, compare (ip & mask) == (base & mask); validate input and test /0, /32, range edges and invalid addresses. Use ipaddress / a prefix trie in production.

Detailed answer· ~110 words

Interview Prep

Unlock the full answer with Interview Prep

Get a ~110-word model answer and a runnable reference solution, plus 3 more Computer Networks questions.

Also in Pro (₹499 / 90 days).

Reference solution· runs in the browser sandbox

Interview Prep
Unlock with Interview Prep

+ 3 more Computer Networks questions in Interview Prep, each with the full answer.

Discussion