below is the code that beats 9.96% run times, O(n), run time 140ms. but i think it minimizes the call of "bool knows(a, b)"

```
public class Solution extends Relation {
public int findCelebrity(int n) {
int cand = 0; // set 0 as current candidate
int prevOneKnowsCand = -1;
for (int i=1; i<n; ++i) { // if cand knows i, celebrity must not be this cand, set cand to i. otherwise, i must not be the celebrity, skip it.
if (knows(cand, i)) {
prevOneKnowsCand = cand; // at least we've already known that "cand" knows the future candidate i
cand = i;
}
} // at this point, cand does not know anyone coming after him
for (int i=0; i<cand; ++i) { if (knows(cand, i)) { return -1; } } // at this point, cand does not know anyone else
for (int i=0; i<n; ++i) {
if (i!=cand && i!=prevOneKnowsCand) { // these 2 ppl know candidate for sure
if (!knows(i, cand)) { return -1; } }
}
return cand;
}
}
```

below is the code that beats 99.82% run times, O(n), run time 12ms.

```
public class Solution extends Relation {
public int findCelebrity(int n) {
int cand = 0; // set 0 as current candidate
// int prevOneKnowsCand = -1;
for (int i=1; i<n; ++i) { // if cand knows i, celebrity must not be this cand, set cand to i. otherwise, i must not be the celebrity, skip it.
if (knows(cand, i)) {
// prevOneKnowsCand = cand; // at least we've already known that "cand" knows the future candidate i
cand = i;
}
} // at this point, cand does not know anyone coming after him
for (int i=0; i<cand; ++i) { if (knows(cand, i)) { return -1; } } // at this point, cand does not know anyone else
for (int i=0; i<n; ++i) {
// if (i!=cand && i!=prevOneKnowsCand) { // these 2 ppl know candidate for sure
if (!knows(i, cand)) { return -1; } // }
}
return cand;
}
}
```

why using IF-Statement so slow??? i mean, it should be slower, but maybe not this slow...