Magicsheet logo

Determine if Two Events Have Conflict

Easy
45.6%
Updated 6/1/2025

Asked by 2 Companies

Determine if Two Events Have Conflict

What is this problem about?

The Determine if Two Events Have Conflict interview question provides two time intervals, each represented as [startTime, endTime] in "HH:MM" format. You need to return true if the events overlap at any point (including touching at the same minute).

Why is this asked in interviews?

Goldman Sachs and Google use this to test your ability to handle non-standard numeric formats. It evaluations how you approach interval comparison and whether you can transform strings into a comparable format (like total minutes from midnight). It’s a basic test of "Overlap Logic" found in calendar and scheduling applications.

Algorithmic pattern used

The problem uses Interval Comparison. Two intervals [a, b] and [c, d] conflict if a <= d and c <= b. The most robust way to handle the "HH:MM" format is to compare the strings directly (since they are zero-padded and fixed length) or convert them to integers representing the total minutes since the start of the day.

Example explanation

Event 1: ["01:15", "02:00"], Event 2: ["02:00", "03:00"].

  1. Event 1 ends at "02:00".
  2. Event 2 starts at "02:00".
  3. Since they touch, they conflict. Result: true. Event 1: ["10:00", "11:00"], Event 2: ["14:00", "15:00"].
  4. Event 1 ends long before Event 2 starts.
  5. "11:00" < "14:00". Result: false.

Common mistakes candidates make

  • Complex Parsing: Trying to use complex regex or date libraries for a simple time comparison.
  • Boundary conditions: Thinking that events don't conflict if they only touch at the exact same minute.
  • Wrong Condition: Using a < c < b instead of the more general start1 <= end2 && start2 <= end1.

Interview preparation tip

For "HH:MM" format problems, string comparison works perfectly because "10:30" is lexicographically greater than "09:45". You don't even need to convert to minutes unless you need to calculate the duration.

Similar Questions