Ezvor

277. Find the Celebrity

MediumTwo Pointers Preparing judge… LeetCode
Two PointersGraph TheoryInteractive

Hints

Hint 1
The best hint for this problem can be provided by the following figure:
Hint 2
Well, if you understood the gist of the above idea, you can extend it to find a candidate that can possibly be a celebrity. Why do we say a "candidate"? That is for you to think. This is clearly a greedy approach to find the answer. However, there is some information that would still remain to be verified without which we can't obtain an answer with certainty. To get that stake in the ground, we would need some more calls to the knows API.