Snap·Software Engineer·Technical Phone Screen
- Given n people labeled 0 to n-1, find the 'celebrity' using an API that tells you whether person A knows person B. A celebrity is known by everyone but knows no one. Solve it in O(n) API calls, or return -1 if no celebrity exists.
“The O(n) constraint is what makes this interesting.”