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
Experiences
Practice
Mock InterviewsTimed interview simulations with feedbackCoaching1:1 coaching with people at your target companiesSuccess 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
Build my plan
Parse Nested Deployment Logs
00:00
5 left

Parse Nested Deployment Logs

HardPython

Problem

Given a list of log lines logs, return the names of all services whose deployment sessions end in an invalid state. Each line is a string in one of these forms: START service_name, END service_name, or ERROR service_name. A service is invalid if its events are not properly nested, if an END appears without a matching open START, if names mismatch on close, if an ERROR occurs while that service is active, or if the service remains open after all logs are processed. Return the invalid service names in sorted order without duplicates.

Constraints

  • 1 <= len(logs) <= 10^5
  • Each log line has exactly two space-separated tokens
  • Event is one of START, END, ERROR
  • 1 <= len(service_name) <= 50
  • Service names contain only letters, digits, _, or -

Function Signature

def find_invalid_services(logs):
Interviewer

Your question is Parse Nested Deployment Logs. 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.