Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Validate Test Lifecycle Sequence

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

Your question is Validate Test Lifecycle Sequence. 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 lifecycle event strings events, determine whether the sequence is valid. Each event is one of "PLAN", "EXECUTE", "DEFECT", "RETEST", or "CLOSE". A valid sequence must follow these rules: PLAN must occur before any other event, EXECUTE can occur only after PLAN, every DEFECT must be matched by a later RETEST, and CLOSE can appear only once at the end after all defects have been retested. Return True if the sequence is valid, otherwise return False.

Constraints

  • 1 <= len(events) <= 10^5
  • Each events[i] is one of "PLAN", "EXECUTE", "DEFECT", "RETEST", "CLOSE"
  • CLOSE, if present, must be the final event in a valid sequence

Function Signature

def validate_lifecycle(events):
Your solutionPython 3
You need to log in / sign up to run or submit.
Run your code to see test output