celebrityCandidate
to 0, assuming the first person might be the celebrity.i
, check if celebrityCandidate
knows i
.
true
, set celebrityCandidate
to i
because the current celebrityCandidate
cannot be the celebrity.false
, continue because i
cannot be the celebrity.celebrityCandidate
is the only potential celebrity.celebrityCandidate
is known by everyone and knows no one else.celebrityCandidate
. Otherwise, return -1
.