Microsoft LLD interview Problem: Design a meeting scheduler

Step 1) Clarify requirements (VERY IMPORTANT in interviews)

Functional Requirements

  • Schedule a meeting
  • Add participants
  • Check conflicts
  • Reject meeting if conflict exists

Not so important features (to keep LLD simple for interview)

  • Notifications
  • UI
  • Time zones
  • Recurring meetings
  • Persistence (DB)

Step 2) Identify Core entities

  • User
    class User {
        String id,
        String name
    }
  • TimeSlot
    class TimeSlot {
        int start,
        int end,
        boolean overlaps(TimeSlot other) {
            // core logic
            return this.start < other.end && other.start < this.end;
        }
    }
    This overlap logic is VERY IMPORTANT
    It handles all conflict cases
  • Meeting
    class Meeting {
        String id,
        List<User> participants
        TimeSlot timeSlot;
    }

Step3) Code a particular feature

I was asked: Where does conflict checking happen?

My thought process:

“I model meetings with time slots and participants.
While scheduling a new meeting, I compare it with existing meetings.
If time overlaps and at least one participant is common, I reject it.”

Scheduler’s job

Knows all meetings

Decides whether a new meeting is allowed

  • Scheduler
    class MeetingScheduler {
    List<Meeting> meetings = new ArrayList<>();
    boolean schedule(Meeting newMeeting){
       for(Meeting existing: meetings){
           // check conflict
           if(hasConflict(existing,newMeeting)) return false;
       }
       meetings.add(newMeeting)
       return true;
    }
    
    private boolean hasConflict(Meeting m1, Meeting m2) {
       if (!m1.timeSlot.overlaps(m2.timeSlot)) return false;
    
       Set<String> users = new HashSet<>();
       for (User u : m1.participants) users.add(u.id);
    
       for (User u : m2.participants) {
           if (users.contains(u.id)) return true;
       }
       return false;
    }

Then some discussion on conflicts, locks, optimizations in existing implementation, tradeoffs, some HLD discussion

VERDICT: SELECTED

Comments (2)