30. The Celebrity Problem
β GFG solution to the Celebrity Problem: find the celebrity in a party using optimal linear elimination technique. π
π§© Problem Description
π Examples
Example 1
Input: mat[][] = [[1, 1, 0],
[0, 1, 0],
[0, 1, 1]]
Output: 1
Explanation: 0th and 2nd person both know 1st person and 1st person does not know anyone.
Therefore, 1 is the celebrity person.Example 2
Input: mat[][] = [[1, 1],
[1, 1]]
Output: -1
Explanation: Since both the people at the party know each other. Hence none of them is a celebrity person.Example 3
π Constraints
β
My Approach
Linear Elimination Algorithm
π Time and Auxiliary Space Complexity
π§ Code (C)
π§βπ» Code (C++)
β Code (Java)
π Code (Python)
π§ Contribution and Support
πVisitor Count
Last updated