← Headway Interview Insights

Headway·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
Jul 2026

Summary

Headway SWE interview, part of a three-question object-oriented design scenario. The coding portion was heavier on design thinking than raw algorithms, which I wasn't fully expecting.

Questions Asked (1)

Q1

Given a log file of road events parsed into objects with types ENTRY, MAINROAD, and EXIT, write a function that counts the total number of complete journeys across all vehicles. Events from different vehicles may be interleaved, so you need to group by vehicle identifier.

Algorithms & Data StructuresData Modeling
Author's notes

This was part two of a three-part scenario so I came in with some context already built up, which helped.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Clarify the event semantics and what constitutes a complete journey (e.g., ENTRY → MAINROAD → EXIT). Then design a solution that groups events by vehicle ID, tracks each vehicle's state, and counts when a valid journey completes, handling edge cases like missing events or out-of-order timestamps.

Pro tip: Mention that you'd validate the input and discuss how to handle incomplete or malformed journeys, showing you think about real-world data quality. Also, consider using a state machine per vehicle to make the logic clear and extensible.

1. Clarify requirements and assumptions

Ask questions to confirm the definition of a complete journey, the expected event sequence, and how to handle edge cases like missing events or duplicate entries.

2. Choose data structures

Decide on a map (hash table) to group events by vehicle ID and a state representation (e.g., enum or flags) to track each vehicle's progress through the journey.

3. Process events and update state

Iterate through the events in order, updating each vehicle's state based on event type, and increment a counter when a vehicle completes a valid journey.

4. Handle edge cases and finalize

Account for incomplete journeys, out-of-order events, and multiple journeys per vehicle; ensure the counter only increments for complete sequences.

Key Points to Mention

  • Grouping events by vehicle identifier using a hash map for O(1) average access.
  • Defining a state machine per vehicle to track progression (e.g., WAITING_FOR_ENTRY, ON_MAINROAD, COMPLETED).
  • Handling interleaved events by processing in timestamp order or assuming input is sorted.
  • Counting only complete journeys (ENTRY → MAINROAD → EXIT) and ignoring incomplete sequences.
  • Considering multiple journeys per vehicle and resetting state after a completed journey.
  • Discussing time and space complexity: O(n) time, O(v) space where v is number of vehicles.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.