Daily challenge for 2025-06-02
153. Find the Celebrity
Write a function solve that finds the celebrity in a party of n people labeled from 0 to n-1. A celebrity is someone who is known by everyone but doesn't know anyone. You are given a helper function knows(a, b) which returns true if person a knows person b, and false otherwise. Your function should return the celebrity's label if there is exactly one celebrity, or -1 if there is no celebrity.
Example:Input: n = 3, knows = [[0,1,true], [0,2,true], [1,0,false], [1,2,true], [2,0,false], [2,1,false]]Output: 2
Explanation: Person 2 doesn't know anybody but is known by everyone.
Run this challenge interactively in Python or JavaScript when the app loads.