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
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🥹🥹🥹
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.
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.
@@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
1:34 , Yes you are , The GOAT of DSA for a reason!❤
Considering all the efforts and contributions you are the real celebrity vaiya. Thanks for everything.
waiting for this stack and queue playlist its finally here , many thanks to @takeuforward for the amazing content
Sir ji why is the celebrity problem in the stack/queue topic? didn't see any stack/queue usage
Same doubt...did you get any answer for it
Same doubt did you know the answer yet 😂
Vhi soch rha hoon 🥲
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
@@harshitminhas5875 99% Correct
i think it would be top++ down -- instead of top-- and down -- for else condition inside the while loop
Yes
common sense, you can correct it yourself.
Is this course is completed?@@kanishkaparwal3060
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🥹🥹🥹
Yes, you are the celebrity Sir
great solution
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.
yaa ,I was also thinking of this while watching
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.
arre gajab bhai
wonderful intution and thought process
easy problem only thing to evaluate that there will be either o or 1 celebrity
Hi but we did not use stack or queue in this
1:34 , Yes you are 😂😂😂
Thank you.
int celebrity(vector& M, int n) {
int top=0;
int bottom= n-1;
while(topbottom) return -1;
for(int i=0;i
celebrity to ho aap.
thanks sir
thanks
Hello, which tool you are using to write on a ipad. I want to install that tool for my sessions
every other people knows the celebrity 1 but 1 doesn't know himself ?😅
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
Yes, you are famous.
I have a doubt
why is this a stack problem ?
You can solve it by stack also which I did when i first saw the question
Achha doubt he bhai😂
@@RAJPATEL-ir7ly could you please explain how can you solve this using a stack?
@@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