Given M busy-time slots of N people, You need to print all the available time slots when all the N people can schedule a meeting for a duration of K minutes.
1) Create a bit array busy[ ] of size equal to total no of minutes per day which is 24*60=1440.
busy[i] = 1 mean minute is busy because of some meeting going on.
busy[i] = 0 mean minute is free and another meeting can be organized.
i represent that minute from the day, ex: For 10:30, i would be 10*60+30 = 630
2) For each input interval, fill busy[i] array on that interval.
3) After each input interval is processed, start scanning busy[ ] array from 0 to 1440 for k continuous
free minutes.And whenever you find the interval print the interval. There may be more than 1 such
interval.
Java code from http://javatroops.blogspot.com/2012/10/interviewstreet-amazon-india-meeting.html
1) Create a bit array busy[ ] of size equal to total no of minutes per day which is 24*60=1440.
busy[i] = 1 mean minute is busy because of some meeting going on.
busy[i] = 0 mean minute is free and another meeting can be organized.
i represent that minute from the day, ex: For 10:30, i would be 10*60+30 = 630
2) For each input interval, fill busy[i] array on that interval.
3) After each input interval is processed, start scanning busy[ ] array from 0 to 1440 for k continuous
free minutes.And whenever you find the interval print the interval. There may be more than 1 such
interval.
Java code from http://javatroops.blogspot.com/2012/10/interviewstreet-amazon-india-meeting.html
Read full article from Just Programming...: Interviewstreet Meeting Schedules - Amazon India Coding Challenge : Solution C++int j; i=0; while(i<1440) { j=i; if(busy[j] == 1) { i++; continue; } while(j < 1440 && busy[++j]!=1); if((j-i)>=k) { //cout << i << " " << j << endl; print(i); cout << " "; print(j); cout << endl; } i=j; } //cin >> i; }