Replay an ADAS Engagement State Machine and Flag Illegal Transitions

Last updated: November 29, 2026

Quick Overview

Given time-ordered events (power_on, engage, disengage, takeover, fault, reset, power_off) for a driver-assistance feature that starts OFF at t=0, replay the state machine, log illegal events without changing state, and return total seconds spent ACTIVE.

Applied Intuition
Coding & Algorithms
Software Engineer
Applied Intuition
November 29, 2026
Software Engineer
Online Assessment
Coding & Algorithms
Easy

0

0

0 solved


Given time-ordered events (power_on, engage, disengage, takeover, fault, reset, power_off) for a driver-assistance feature that starts OFF at t=0, replay the state machine, log illegal events without changing state, and return total seconds spent ACTIVE.

Applied Intuition helps customers validate driver assistance features, and checking logs against a specified mode diagram is a common tooling task. The interviewer checks a table-driven state machine and correct time accounting at the end of the log.

What the Interviewer Expects
  • Encode transitions as a lookup table instead of nested ifs
  • Ignore and record illegal events without corrupting state
  • Accumulate active time when leaving ACTIVE
  • Close out an ACTIVE interval at end of log
  • Return the final state for downstream checks
Key Topics to Cover
state machines
simulation
table-driven design
log validation
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
  • How would you report the longest single engagement?
  • How would you add a timeout so STANDBY returns to OFF after 60 seconds?
  • How would you generate test event sequences that cover every transition?
  • How would you run this over a fleet's logs in parallel?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice DSA Problems
Sample Answer
Requirements

Events are (t, name) sorted by t. Allowed transitions: OFF to STANDBY on power_on; STANDBY to ACTIVE on engage; ACTIVE to STANDBY on disengage or takeover; STANDBY or ACTIVE to FAULT on fault; FAULT...

High-Level Design

A dict keyed by (state, event) gives the next state. For each event, a missing key is a violation (t, state, event) and the state stays put. On a legal transition out of ACTIVE, add t - since. A...


Submit Your Answer
Markdown supported

Related Questions