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
Mark Machines Offline
00:00
5 left

Mark Machines Offline

MediumPython

Problem

Identify relevant machines based on returned parameters and send an HTTP POST request to mark them offline.

Implement the function below. Each machine has an id and parameter map. A machine is relevant when it matches every key-value pair in at least one returned-parameter filter. Return one POST request per relevant machine, preserving input order and removing duplicate machine IDs.

The returned request format is {method, url, json}, with URL /machines/{id}/offline and JSON body {"status": "offline"}.

Constraints

  • 1 <= len(machines) <= 5000
  • 0 <= len(returned_params) <= 5000
  • Each machine has a unique non-empty string id
  • Each parameter map has at most 20 key-value pairs
  • Parameter keys and values are hashable strings or numbers
  • A filter matches a machine only when all of its key-value pairs match
  • An empty filter matches every machine

Function Signature

def mark_relevant_machines_offline(machines, returned_params):
Interviewer

Your question is Mark Machines Offline. 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.
Code
Sign up free to run your codeLog inLn 2
Run your code to see test output here.