LC: Find the Celebrity - spiralgo/algorithms GitHub Wiki
The Essence:
- The celebrity won't know anyone after their index.
- The celebrity won't know anyone before their index.
- Everyone will know the celebrity.
Using these 3 facts, the procedure can logically deduce who is the celebrity if there is any in 3 loops.
Details:
Implementation can be found here: https://github.com/spiralgo/algorithms/blob/master/src/main/java/algorithms/curated170/medium/FindTheCelebrity.java