https://practice.geeksforgeeks.org/problems/the-celebrity-problem/1/?track=SPC-Stack&batchId=154
class Celebrity
{
// The task is to complete this function
int getId(int M[][], int n)
{
Stack s=new Stack<>();
for(int i=0;i<n;i++)
{
s.push(i);
}
int a,b;
while(s.size()>1){
a=s.pop();
b=s.pop();
if(checkKnown(M,a,b))
s.push(b);
else
s.push(a);
}
int celeb= s.pop();
for(int i=0;i<n;i++)
{
if((i!=celeb) && (checkKnown(M,celeb,i)) || (!checkKnown(M,i,celeb)))
return -1;
}
return celeb;
}
boolean checkKnown(int M[][],int a,int b)
{
return M[a][b]==1?true:false;
}
}