L17. The Celebrity Problem | Stack and Queue Playlist

Поділитися
Вставка
  • Опубліковано 14 лис 2024

КОМЕНТАРІ • 58

  • @harshvardhan1214
    @harshvardhan1214 3 місяці тому +62

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

  • @mrminus8590
    @mrminus8590 4 місяці тому +13

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

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

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

  • @vishalsagar1437
    @vishalsagar1437 3 місяці тому +19

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

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

      Yes

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

      common sense, you can correct it yourself.

    • @deepakff7498
      @deepakff7498 3 місяці тому

      Is this course is completed?​@@kanishkaparwal3060

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

    Oh GOD, I was about to say yeah you are the celebrity, but it sounds more good when he said it himself. Now let's get back to the video.

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

    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 4 місяці тому +3

    Yes, you are the celebrity Sir

  • @shikhirkalia6828
    @shikhirkalia6828 3 місяці тому +36

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

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

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

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

      Same doubt did you know the answer yet 😂

    • @VikasYadu11
      @VikasYadu11 3 місяці тому

      Vhi soch rha hoon 🥲

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

      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 3 місяці тому

      @@harshitminhas5875 99% Correct

  • @pratyushbhatt1712
    @pratyushbhatt1712 27 днів тому +4

    How is this problem related to stack and queue?

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

    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.

  • @charuprabha8714
    @charuprabha8714 3 місяці тому +5

    Hi but we did not use stack or queue in this

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

    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 3 місяці тому

      yaa ,I was also thinking of this while watching

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

    If top does not know down and down does not know top as well then top and down both will not move and will cause runtime error.
    I think you should explain that part like this:-
    while (low < high) {
    if (M[low][high] == 1) {
    // Case 1: low knows high => low cannot be the celebrity
    low++;
    } else {
    // Case 2: low does not know high => high cannot be the celebrity
    high--;
    }
    }

    • @kritwaneditz9006
      @kritwaneditz9006 28 днів тому

      else low++ high--; because they both cannot be the celeibrity//////////////// add this condition

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

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

  • @MIRIYALASaiKrishna
    @MIRIYALASaiKrishna 3 місяці тому

    wonderful intution and thought process

  • @atulwadhwa192
    @atulwadhwa192 8 днів тому

    what is the intuition? Also why do I need to check?

  • @TOI-700
    @TOI-700 Місяць тому

    GETTING YOU BROTHER RAJ

  • @swarupdas4114
    @swarupdas4114 День тому

    Optimal Solution - 7:48

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

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

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

    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

  • @sawan-i6u
    @sawan-i6u 3 місяці тому +1

    celebrity to ho aap.

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

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

  • @karthik-varma-1579
    @karthik-varma-1579 Місяць тому +1

    I didnot understand why did you teach celebrity problem in stack and queue playlist. I thought tis problem can be solved using stack and queues you taught bruteforce and the optmal using two pointers and where is the stack approach

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

      u can also solve this using stack

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

    great solution

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

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

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

    thanks striver

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

    thanks bhaiya

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

    using stack we can have a better(between brute and optimal) solution with TC-O(2*n) and SC-O(n)
    int findCelebrity(int n) {
    stackst;
    for(int i(0);i

    • @keshavbadhekar
      @keshavbadhekar 24 дні тому

      we have O(1) space complexity in optimal solution and your solution having O(N); how can your solution is better than optimal?
      but yes, thanks for giving solution using Stack as this problem is included in stack and queue playlist.

  • @subee128
    @subee128 3 місяці тому

    Yes, you are famous.

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

    I have a doubt
    why is this a stack problem ?

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

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

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

      Achha doubt he bhai😂

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

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

    • @ashwathkrishnan
      @ashwathkrishnan 3 місяці тому +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

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

    Thank you.

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

    UNDERSTOOD;

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

    thanks sir

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

    1:34 , Yes you are 😂😂😂

  • @sanchitdeepsingh9663
    @sanchitdeepsingh9663 3 місяці тому

    thanks

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

    🙃