Interview Questions

190. A mail server exposes an interface as mentioned below ......

Microsoft Interview Questions and Answers


(Continued from previous question...)

190. A mail server exposes an interface as mentioned below ......

Question:
A mail server exposes an interface as mentioned below. When given a day in the calendar a user, it gets the meetings mentioned as slots in calendar with start and end time for each meeting.

CalendarSlot *GetMeetings(char[] username, unsigned int day);
typedef struct
{
unsigned int StartTime;
unsigned int endTime;
}CalendarSlot

The developer has implemented a mail client function as mentioned below. This function takes in a list of users, internally uses the GetMeetings mail server interface to get the list of meetings for those users. Eventually, it gives out the first 10 free slots, within the next 3 days from the day specified, which is of the mentioned slotDuration. Everyone in the userList have to be free from meetings during these slots returned, without exception.

Assumptions:
1. Meeting start time and end times will align at the beginning of an hour (8:00,9:00etc....)
2. SlotDuration will be in multiple of full hours (1hrs, 2hrs,etc....)

CalendarSlot * GetFreeSlots (char [][] userList, unsigned int day, unsigned int slotDuration)

Write the test cases for testing GetFreeSlots function. NOTE: Assume that GetMeetings function is already well tested.


maybe an answer:


There is only a finite number of slots available on any day. So an array can be used to represent it freeslots[24], indexed by start time normalized to UTC. As you process each users meetings, update freeslots[] array and mark the slots NOTFREE. Then, process freeslots[] array and return unmarked or FREE slots (combine contiguous ones) if they match the requested duration.

(Continued on next question...)

Other Interview Questions