Skip to content
This repository has been archived by the owner on Oct 1, 2021. It is now read-only.

Commit

Permalink
Create CelebrityProblem.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
harshsngh109 authored Oct 1, 2020
1 parent 414975f commit 6d57f77
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions Language/C++/CelebrityProblem.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
int getId(int M[MAX][MAX], int n)
{
int cel = 0;
for (int i = 1; i < n; i++)
if (M[cel][i])
cel = i; //prev cel can't be celebrity
for (int i = 0; i < n; i++)
if ((cel != i) && (M[cel][i] || !M[i][cel]))
return -1;
return cel;
}

0 comments on commit 6d57f77

Please sign in to comment.