Dataford
Interview QuestionsInterview GuidesExperiencesCoaching
New
Pricing
Get started
Dataford
Popular roles
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Browse
Browse All RolesEvery role hub, from analyst to MLBrowse All CompaniesCompany-specific interview loopsAll Interview GuidesThe full guide library
Top questions by role
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Top questions by skill
SQLPythonStatisticsMachine LearningA/B TestingSystem DesignGenerative AIProduct SenseMetricsBehavioral
Browse all questions →Try a mock interview
ExperiencesCoaching
New
Practice
Mock InterviewsTimed interview simulations with feedbackSuccess PathYour 6-week structured planModulesCurated lessons by topicWebinarsTalks from ex-Big Tech data leadsPlaygroundA free-form scratch editor
Learn
BlogInterview strategy and career adviceTech Job Market ReportHiring trends across data and AI rolesFor UniversitiesDataford for career centersAbout DatafordWho we are and how we build
Pricing
Get started
Subnetting, Semaphores, and Classical Protocols
00:00
5 left

Subnetting, Semaphores, and Classical Protocols

HardPython

Problem

Explain how you would implement subnetting and then code a classical networking concept such as the three-way handshake or virtual memory, while also reasoning about semaphores.

Implement the subnetting and three-way handshake option. The function receives an IPv4 CIDR, a power-of-two subnet count, an ordered event stream, and a semaphore capacity. Return the generated subnet CIDRs and each connection's final state.

I/O Contract

def subnet_and_handshake(network_cidr, subnet_count, events, semaphore_limit): Input events are dictionaries with connection and event, where events are SYN, SYN-ACK, ACK, or RST. Each connection must complete SYN -> SYN-ACK -> ACK to become established.

Constraints

  • network_cidr is a valid IPv4 CIDR network
  • 1 <= subnet_count <= 256
  • subnet_count is a power of two
  • The resulting prefix length is at most 32
  • 1 <= semaphore_limit <= 10^4
  • 0 <= len(events) <= 10^4
  • Each event contains a string connection identifier and one valid event name

Function Signature

def subnet_and_handshake(network_cidr, subnet_count, events, semaphore_limit):
Interviewer

Your question is Subnetting, Semaphores, and Classical Protocols. Start with the requirements in the Question tab.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.
CodePython 3
Sign up free to run your codeLog inLn 2
Run your code to see test output here.