Katkat

Track Users From Flight History

RampSoftware Engineer · Technical Screen

Last updated

This question evaluates competency in processing and aggregating temporal event data, including time-interval reasoning, counting/grouping per user, and designing efficient data structures and algorithms for large datasets.

You are given an unsorted list of flight records. Each record contains departure_airport, departure_time, arrival_airport, arrival_time, and user_id.

Assume:

  • Timestamps are ISO-8601 UTC strings.
  • Flights for the same user do not overlap.
  • A user's status at a given time is:
  • unknown before their first recorded departure,
  • in_transit(departure_airport, arrival_airport) between departure and arrival,
  • the airport where they most recently landed or are waiting to depart between two flights.

Implement two functions:

  1. get_user_with_most_flights(flights): return the user_id with the largest number of flight records. If multiple users tie, return any one of them.
  2. get_user_locations(flights, time): given a timestamp, return the location or travel status of every user at that time.

Your solution should handle large inputs efficiently.