Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Parse Nested Deployment Logs

HardPython00:00
Practice interviewer
In session
5 left
00:00

Your question is Parse Nested Deployment Logs. Start with the requirements on the right.

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.

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):
Your solutionPython 3
You need to log in / sign up to run or submit.
Run your code to see test output