277. Find the Celebrity

Problem

Given n people, find the celebrity who is known by everyone but knows nobody, or return -1.

Suppose you are at a party with n people labeled 0 to n-1. There is a "knows" API that returns whether person a knows person b. Find the celebrity if one exists:

  • Everyone knows the celebrity
  • The celebrity knows no one

If no celebrity exists, return -1.

Examples
Input: [[],0]
Output: [0,0,0,0,0]
Hints
Related Problems

277. Find the Celebrity

Given n people, find the celebrity who is known by everyone but knows nobody, or return -1.