Dataford
Interview QuestionsInterview GuidesExperiencesCoaching
New
Pricing
Get started
Dataford
Popular roles
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Browse
Browse All RolesEvery role hub, from analyst to MLBrowse All CompaniesCompany-specific interview loopsAll Interview GuidesThe full guide library
Top questions by role
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Top questions by skill
SQLPythonStatisticsMachine LearningA/B TestingSystem DesignGenerative AIProduct SenseMetricsBehavioral
Browse all questions →Try a mock interview
ExperiencesCoaching
New
Practice
Mock InterviewsTimed interview simulations with feedbackSuccess PathYour 6-week structured planModulesCurated lessons by topicWebinarsTalks from ex-Big Tech data leadsPlaygroundA free-form scratch editor
Learn
BlogInterview strategy and career adviceTech Job Market ReportHiring trends across data and AI rolesFor UniversitiesDataford for career centersAbout DatafordWho we are and how we build
Pricing
Get started
Detect Booking Time Overlaps
00:00
5 left

Detect Booking Time Overlaps

EasyPython

Problem

Turo needs to determine whether a specific vehicle has conflicting bookings. Given booking records and a vehicle ID, return True if any two bookings for that vehicle overlap, otherwise return False.

Treat each booking interval as half-open: [start, end). Therefore, a booking ending at time 10 does not overlap a booking starting at time 10.

Formal Specification

Implement detect_booking_overlap(bookings, vehicle_id). bookings is a list of dictionaries, each containing:

  • vehicle_id: a string
  • start: an integer start timestamp
  • end: an integer end timestamp

Return a boolean. Only bookings whose vehicle_id matches the requested vehicle should be considered. The input is not necessarily sorted.

Constraints

  • 0 <= len(bookings) <= 10^5
  • Each booking contains vehicle_id, start, and end
  • start < end for every booking
  • 0 <= start < end <= 10^9
  • The requested vehicle_id is a non-empty string

Function Signature

def detect_booking_overlap(bookings, vehicle_id):
Interviewer

Your question is Detect Booking Time Overlaps. Start with the requirements in the Question tab.

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.
Code
Sign up free to run your codeLog inLn 2
Run your code to see test output here.