L17. The Celebrity Problem | Stack and Queue Playlist

Поділитися
Вставка
  • Опубліковано 16 вер 2024
  • Find problem link, notes under Step 9: takeuforward.o...
    Follow me on socials: linktr.ee/take...

КОМЕНТАРІ • 43

  • @harshvardhan1214
    @harshvardhan1214 Місяць тому +46

    1:34 , Yes you are , The GOAT of DSA for a reason!❤

  • @mrminus8590
    @mrminus8590 2 місяці тому +11

    Considering all the efforts and contributions you are the real celebrity vaiya. Thanks for everything.

  • @bhudevbhanpuriya7243
    @bhudevbhanpuriya7243 2 місяці тому +2

    waiting for this stack and queue playlist its finally here , many thanks to @takeuforward for the amazing content

  • @shikhirkalia6828
    @shikhirkalia6828 Місяць тому +30

    Sir ji why is the celebrity problem in the stack/queue topic? didn't see any stack/queue usage

    • @pragadhishraajmp8871
      @pragadhishraajmp8871 Місяць тому +2

      Same doubt...did you get any answer for it

    • @avengersshorts5949
      @avengersshorts5949 Місяць тому +1

      Same doubt did you know the answer yet 😂

    • @VikasYadu11
      @VikasYadu11 Місяць тому

      Vhi soch rha hoon 🥲

    • @harshitminhas5875
      @harshitminhas5875 Місяць тому +1

      it can also be solved using a stack
      //User function template for C++
      class Solution
      {
      public:
      //Function to find if there is a celebrity in the party or not.
      int celebrity(vector& M, int n)
      {
      // code here
      stack st;
      //push all into stack
      for(int i = 0; i

    • @VikasYadu11
      @VikasYadu11 Місяць тому

      @@harshitminhas5875 99% Correct

  • @vishalsagar1437
    @vishalsagar1437 Місяць тому +12

    i think it would be top++ down -- instead of top-- and down -- for else condition inside the while loop

    • @Cool96267
      @Cool96267 Місяць тому +1

      Yes

    • @kanishkaparwal3060
      @kanishkaparwal3060 Місяць тому

      common sense, you can correct it yourself.

    • @deepakff7498
      @deepakff7498 Місяць тому

      Is this course is completed?​@@kanishkaparwal3060

  • @HMBDM1976
    @HMBDM1976 2 місяці тому +3

    Hi Striver,
    I just wanted to thank you for your incredible DSA tutorials. Your clear explanations and thorough examples have made a huge difference in my understanding and proficiency. Thanks to your videos, I've become very proficient in DSA, which has significantly boosted my confidence and performance in my coding
    Keep up the great work, you're making a big difference! Thank you very much🥹🥹🥹

  • @sachinvarma9949
    @sachinvarma9949 2 місяці тому +2

    Yes, you are the celebrity Sir

  • @rxt740
    @rxt740 4 дні тому

    great solution

  • @subhajitdey135
    @subhajitdey135 Місяць тому +2

    An edge to be considered is what if both arr[i][j]==1 && arr[j][i]==1, so i++,j--;
    so for both if((arr[i][j]==1 && arr[j][i]==1) || (arr[i][j]==0 && arr[j][i]==0)) i++,j--;
    In either case if you dont add this in the code, it will still run fine, mentioned it just to improve readability.

    • @AnkitRaj-mw6tp
      @AnkitRaj-mw6tp Місяць тому

      yaa ,I was also thinking of this while watching

  • @alisheheryar1770
    @alisheheryar1770 23 дні тому +1

    Celebrity should not only nobody but also he should be known by everyone. If he know nobody and nobody know him then he becomes a tik toker, not a celebrity.

  • @MIRIYALASaiKrishna
    @MIRIYALASaiKrishna Місяць тому

    wonderful intution and thought process

  • @ITSuyashTiwari
    @ITSuyashTiwari 2 місяці тому +1

    easy problem only thing to evaluate that there will be either o or 1 celebrity

  • @charuprabha8714
    @charuprabha8714 Місяць тому +2

    Hi but we did not use stack or queue in this

  • @AbhishekGupta-zf2sw
    @AbhishekGupta-zf2sw 2 місяці тому +1

    1:34 , Yes you are 😂😂😂

  • @anupamtiwary4265
    @anupamtiwary4265 2 місяці тому

    Thank you.

  • @anishsood3084
    @anishsood3084 Місяць тому +4

    int celebrity(vector& M, int n) {
    int top=0;
    int bottom= n-1;
    while(topbottom) return -1;
    for(int i=0;i

  • @InnerChampion9
    @InnerChampion9 Місяць тому +1

    celebrity to ho aap.

  • @carcrew_1
    @carcrew_1 2 місяці тому

    thanks sir

  • @sanchitdeepsingh9663
    @sanchitdeepsingh9663 Місяць тому

    thanks

  • @SkillQuestion
    @SkillQuestion 7 днів тому

    Hello, which tool you are using to write on a ipad. I want to install that tool for my sessions

  • @anilkumarakula6045
    @anilkumarakula6045 4 дні тому +1

    every other people knows the celebrity 1 but 1 doesn't know himself ?😅

  • @Cubeone11
    @Cubeone11 15 днів тому

    why are we checking if the top is greater than bottom or not ,cuz the top and bottom would end up at the same position after the while loop

  • @subee128
    @subee128 Місяць тому

    Yes, you are famous.

  • @athul373
    @athul373 2 місяці тому +7

    I have a doubt
    why is this a stack problem ?

    • @RAJPATEL-ir7ly
      @RAJPATEL-ir7ly 2 місяці тому

      You can solve it by stack also which I did when i first saw the question

    • @VinitSoul
      @VinitSoul 2 місяці тому +1

      Achha doubt he bhai😂

    • @KshitijVispute-wb6ze
      @KshitijVispute-wb6ze 2 місяці тому +1

      @@RAJPATEL-ir7ly could you please explain how can you solve this using a stack?

    • @ashwathkrishnan
      @ashwathkrishnan Місяць тому +2

      @@KshitijVispute-wb6ze Instead of using the top and down variables, push all indices from 0 to n into a stack. For each iteration, pop the top 2 elements and check if there is a candidate celebrity. If yes, push the candidate back into the stack. This way, you would be left with 1 element if there is a celebrity. You would still have to perform the final check