Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Live Coding Automation Challenge

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

Your question is Live Coding Automation Challenge. 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

Describe how you would implement and validate an automation solution during a live coding exercise for a QA task.

Implement validate_automation_run(expected_steps, events) to validate an ordered automation event stream. Each event contains a step name and one event type: start, fail, or pass. A step may be retried after fail, but only one attempt may be active at a time. Return { "valid": bool, "error_index": int }, where error_index is the first invalid event index, or -1 for a valid complete run.

Examples: ['login', 'checkout'] with start, pass, start, pass is valid. A pass without a matching start, an out-of-order step, or an incomplete final step is invalid.

Constraints

  • 1 <= len(expected_steps) <= 10^5
  • 0 <= len(events) <= 2 * 10^5
  • Step names are unique strings
  • Each event contains step and event keys
  • Event types are intended to be start, fail, or pass

Function Signature

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