int maximumMeetings(vector &start, vector &end) { vector v; int n = start.size(); for(int i=0;i time) { ans++; time = item.second; } } return ans; } int this code , i dont need to store the position anywhere , just store both of those in a vector of pairs, i think this code is better than the given video
Easy java solution: public static int maxMeetings(int start[], int end[], int n) { List list = new ArrayList(); for(int i=0;i lst.get(2))); int freeTime = 0; int count = 0; for(int i=0;i
static class meeting{ int start; int end; public meeting(int s,int e){ this.start=s; this.end=e; } } public static int maxMeetings(int start[], int end[], int n) { meeting m[]=new meeting[n]; for(int i=0;ia.end-b.end); int count=0; int prev=0; int s=0; int e=0; for(int i=0;im[prev].end){ // count++; // prev=i; // } if(m[i].start>e){ count++; e=m[i].end; } } return count; }
Another way to think about this is to sort by start time in asc order. While keeping track of lastEnd time, when evaluating times[i] , there are 2 cases 1. there is no overlap; - update lastEnd time to times[i][1] - count++ 2. there is an overlap ( times[i][0]
@takeUforward I have a question regarding this. Why minimum platform doesnt work here? I mean if I try to calculate minimum meeting rooms and then assign 1 meetings to each of one rooms and rest to just one room
this might not work for the case in which there is no 0-5 and no 1-2 and it has 0-2 removing the two inputs which are 0-5 and 1-2 and adding the input 0-2 will it work or not clarify it
C++ CODE struct meet{ int start; int end; }; class Solution { public: // Function to find the maximum number of meetings that can // be performed in a meeting room. static bool comp(meet m1,meet m2){ return m1.end
Simple Java Code For Only Meeting Count: class Meeting{ int start; int end; public Meeting(int s, int e){ this.start=s; this.end=e; } } class Solution { public static int maxMeetings(int start[], int end[], int n) { List meetings = new ArrayList(); for(int i=0; i m.end)); int lastEnd= -1; int count=0; for(Meeting meet: meetings){ if(meet.start > lastEnd){ lastEnd=meet.end; count++; } } return count; } }
As you said sort the array based on meeting timing, and process the problem of sorting values, for example if the shortest meeting starts at 20 and other meeting timings are lesser than 20, how would this approach work?