Design a Concurrent Meeting Scheduler with Audit Logging and Capacity Constraints

Difficulty: EASYCategory: LLDFrequency: 1Asked On 2024-06-07

Problem Statement

Design a Meeting Scheduler System that supports scheduling meetings across N rooms, while maintaining audit logs, respecting room capacities, and minimizing spillage of free time.


🎯 Functional Requirements

1. Room Management

•There are N rooms, each with a unique ID and a capacity.

2. Schedule Meeting

•Method: schedule(meetingId, startTime, endTime, requiredCapacity)
•Schedule a meeting in one of the available rooms that:
•Is available during the given time slot.
•Has sufficient capacity.
•Minimizes spillage (i.e., try to avoid blocking longer available slots with short meetings).
•If no room can host the meeting, return failure.

3. Audit Logs

•Maintain an audit log for each scheduled meeting per room.
•Each log includes:
•meetingId
•startTime, endTime
•scheduledAt timestamp
•Logs are stored per room.

4. Delete Expired Logs

•Method: deleteExpiredLogs(xDays)
•Delete audit logs older than x days (from scheduledAt time).


🔄 Non-Functional & Concurrency Requirements

•System must be thread-safe:
•Multiple scheduling and deletion requests may happen concurrently.
•Use locking or concurrent data structures to avoid race conditions.
•Optimize for read-heavy, low-latency scheduling.

➕ Follow-up Feature: Capacity Constraints

•Each meeting has a requiredCapacity.
•Rooms must be filtered by whether they can handle that many attendees.

🧠 Spillage Minimization (Key Constraint)

•A short meeting should not be scheduled in a room that has a longer continuous block available unless no better-fit room is found.

📌 Example:

1text 2CopyEdit 3Room 1: Free from 9–10 4Room 2: Free from 9–12 5Meeting: 9–10, capacity 4 6 7Prefer Room 1 → using Room 2 would waste 2 more hours of available time.


Solution

Comments