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.
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.
START, END, ERROR_, or -def find_invalid_services(logs):