You are given an array representing a group of people, where array[i][j]
is 1 if person i
knows person j
, and 0 otherwise. A celebrity is defined as someone who knows no one but is known by everyone else. Write a function findCelebrity
to determine if there is a celebrity in the group. If there is a celebrity present, return their index (0-indexed), otherwise return -1.
def findCelebrity(n: int, array: List[List[int]]) -> int:
pass
Example:
Input:
n = 4
array = [
[0, 0, 1, 0],
[0, 0, 1, 0],
[0, 0, 0, 0],
[0, 0, 1, 0]
]
Output: 2
Note: