L7. N Meeting in One Room | Greedy Algorithms Playlist
Find problem link, notes under Step 12: takeuforward.org/strivers-a2z... Follow me on socials: linktr.ee/takeUforward
Жүктеу.....
Пікірлер: 27
@KrishnaPatil-qj5qw26 күн бұрын
Kijiye Meeting Meeting, karte rahiye meeting meeting, halua meeting meeting
@ajaynaik2480
5 күн бұрын
🤣
@palgravedmen8519Ай бұрын
Goat is back
@Dsa_kabaapАй бұрын
Sir please start making videos on strings and stacks
@thoughtsofkrishna896325 күн бұрын
Waiting for strings playlist
@KartikeyTT28 күн бұрын
tysm sir
@suhanapriya7070Ай бұрын
Yayyy!
@meme_eternity26 күн бұрын
Understood
@sword0132 күн бұрын
Why is
@harshitjaiswal9439Ай бұрын
understood
@vibhasyadav98022 сағат бұрын
@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
@Professor-du2pfАй бұрын
std :: cout
@top_g755Ай бұрын
How can u say that greedy will always work
@subhasreebanerjee98Ай бұрын
Please also include code explanation in c++ which you used to do, that would be really helpful!
@darkfallmotivation568715 күн бұрын
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?
@siddhantshukla2154
11 күн бұрын
Sorting on basis of ending times, not on the actual length.
@user-iv3jg1jn9z4 күн бұрын
Striver after eating mummy ke haath ka khaana abhi kitne video banane hai bana lenge sab hojayega ,welcome back
@muntajir6463 күн бұрын
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; } }
@solvinglife665829 күн бұрын
Stacks
@LuckyKumar-mt9kmАй бұрын
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
@after_dark_777
Ай бұрын
It's not better, as the space complexity is now O(n^2) rather than O(n) in the solution
@ghufran_khan_
6 күн бұрын
@@after_dark_777 bro space complexity is O(2n) not O(n^2)
@sajalkumarsingh9839Ай бұрын
a better code static bool cmp(pair a,pair b){ return a.second
@harshitvh1Ай бұрын
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
@rishitkamboj8078Ай бұрын
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; }
Пікірлер: 27
Kijiye Meeting Meeting, karte rahiye meeting meeting, halua meeting meeting
@ajaynaik2480
5 күн бұрын
🤣
Goat is back
Sir please start making videos on strings and stacks
Waiting for strings playlist
tysm sir
Yayyy!
Understood
Why is
understood
@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
std :: cout
How can u say that greedy will always work
Please also include code explanation in c++ which you used to do, that would be really helpful!
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?
@siddhantshukla2154
11 күн бұрын
Sorting on basis of ending times, not on the actual length.
Striver after eating mummy ke haath ka khaana abhi kitne video banane hai bana lenge sab hojayega ,welcome back
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; } }
Stacks
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
@after_dark_777
Ай бұрын
It's not better, as the space complexity is now O(n^2) rather than O(n) in the solution
@ghufran_khan_
6 күн бұрын
@@after_dark_777 bro space complexity is O(2n) not O(n^2)
a better code static bool cmp(pair a,pair b){ return a.second
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; }
Understood