L7. N Meeting in One Room | Greedy Algorithms Playlist

Поделиться
HTML-код
  • Опубликовано: 5 окт 2024
  • Find problem link, notes under Step 12: takeuforward.o...
    Follow me on socials: linktr.ee/take...

Комментарии • 43

  • @KrishnaPatil-qj5qw
    @KrishnaPatil-qj5qw 3 месяца назад +62

    Kijiye Meeting Meeting, karte rahiye meeting meeting, alhua meeting meeting

  • @ToonDubberDuo
    @ToonDubberDuo 10 дней назад +1

    i could solve it using the overlapping intervals concept, felt great lol

  • @OrbitZyro
    @OrbitZyro Месяц назад +2

    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]

  • @kaichang8186
    @kaichang8186 2 дня назад

    understood, thanks for the perfect explanation

  • @aruna5869
    @aruna5869 21 день назад +3

    I am feeling like intuition is missing in this problem... does anyone same like me?

  • @UECAshutoshKumar
    @UECAshutoshKumar 17 дней назад +1

    Thank you

  • @naveensingh596
    @naveensingh596 Месяц назад

    Such a great explanation !

  • @palgravedmen8519
    @palgravedmen8519 4 месяца назад +10

    Goat is back

  • @suhanapriya7070
    @suhanapriya7070 4 месяца назад +4

    Yayyy!

  • @Dsa_kabaap
    @Dsa_kabaap 4 месяца назад +10

    Sir please start making videos on strings and stacks

  • @top_g755
    @top_g755 4 месяца назад +2

    How can u say that greedy will always work

  • @vibhasyadav980
    @vibhasyadav980 2 месяца назад +1

    @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

  • @meme_eternity
    @meme_eternity 3 месяца назад +1

    Understood

  • @subhasreebanerjee98
    @subhasreebanerjee98 4 месяца назад +6

    Please also include code explanation in c++ which you used to do, that would be really helpful!

    • @subratamandal2924
      @subratamandal2924 Месяц назад

      Hey Bengali. Which college currently are you in?

  • @thoughtsofkrishna8963
    @thoughtsofkrishna8963 3 месяца назад +5

    Waiting for strings playlist

  • @sajalkumarsingh9839
    @sajalkumarsingh9839 3 месяца назад +5

    a better code
    static bool cmp(pair a,pair b){
    return a.second

  • @muntajir646
    @muntajir646 2 месяца назад

    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;
    }
    }

  • @KartikeyTT
    @KartikeyTT 3 месяца назад +1

    tysm sir

  • @harshitjaiswal9439
    @harshitjaiswal9439 4 месяца назад +1

    understood

  • @LuckyKumar-mt9km
    @LuckyKumar-mt9km 3 месяца назад

    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
      @after_dark_777 3 месяца назад

      It's not better, as the space complexity is now O(n^2) rather than O(n) in the solution

    • @ghufran_khan_
      @ghufran_khan_ 2 месяца назад +1

      @@after_dark_777 bro space complexity is O(2n) not O(n^2)

  • @darkfallmotivation5687
    @darkfallmotivation5687 2 месяца назад

    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
      @siddhantshukla2154 2 месяца назад +2

      Sorting on basis of ending times, not on the actual length.

  • @subee128
    @subee128 Месяц назад

    Thanks

  • @abhishekkumar-ot4zo
    @abhishekkumar-ot4zo 24 дня назад

    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

  • @deveshsharma-u2l
    @deveshsharma-u2l 2 месяца назад

    Striver after eating mummy ke haath ka khaana abhi kitne video banane hai bana lenge sab hojayega ,welcome back

  • @Professor-du2pf
    @Professor-du2pf 4 месяца назад +3

    std :: cout

  • @solvinglife6658
    @solvinglife6658 3 месяца назад +1

    Stacks

  • @sword013
    @sword013 2 месяца назад

    Why is

    • @avengergirl_0464
      @avengergirl_0464 23 дня назад +1

      Bcoz it is given in problem statement that the start time of other meeting cannot be equal to end time of prev meeting..it must be greater

  • @harshitvh1
    @harshitvh1 3 месяца назад

    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

  • @CryptoBoy0111
    @CryptoBoy0111 Месяц назад

    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

  • @rishitkamboj8078
    @rishitkamboj8078 3 месяца назад +1

    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;
    }

  • @naveen_satyarthi
    @naveen_satyarthi 26 дней назад

    struct Meeting{
    int start;
    int end;
    int pos;
    };
    bool meetingComparator(Meeting m1, Meeting m2) {
    if(m1.end < m2.end)
    return true;
    else
    return false;
    }
    class Solution {
    public:
    int maxMeetings(int n, int start[], int end[]) {
    vector meetings(n);
    for(int i = 0; i < n; i++){
    meetings[i].start = start[i];
    meetings[i].end = end[i];
    meetings[i].pos = i+1;
    }
    sort(meetings.begin(), meetings.end(), meetingComparator); // sort according to the end time..
    int freetime = meetings[0].end;
    int count = 1;
    for(int i = 1; i < n; i++){
    if(freetime < meetings[i].start){
    count++;
    freetime = meetings[i].end;
    }
    }
    return count;
    }
    };

  • @SibiRanganathL
    @SibiRanganathL 22 дня назад

    Understood

  • @RachitKala-cp4uh
    @RachitKala-cp4uh 2 месяца назад

    Understood