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
Automate Incident Data Collection
00:00
5 left

Automate Incident Data Collection

HardPython

Problem

How would you automate the collection of incident response data from running Docker containers on Google Cloud without disrupting production workloads?

Implement a read-only collector that merges per-container incident-event streams without modifying them. Return events in timestamp order, break equal timestamps by container ID, remove duplicate event IDs, and stop after max_records results.

Use collect_incident_data(container_events, max_records). container_events maps container IDs to lists of event dictionaries, each containing event_id, timestamp, kind, and payload; each list is already timestamp-sorted. Return a list of event dictionaries.

Constraints

  • container_events is a mapping from container IDs to timestamp-sorted event lists
  • Each event contains event_id, timestamp, kind, and payload
  • Event IDs are strings and timestamps are comparable integers
  • max_records is a non-negative integer
  • Do not modify container_events or any event dictionary
  • The output contains at most max_records unique events

Function Signature

def collect_incident_data(container_events, max_records):
Interviewer

Your question is Automate Incident Data Collection. 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.