Skip to content
0:00 / 0:00

#celebrityproblem#two-pointertechnique#graphs

The Celebrity Problem | Algorithm Explanation by alGOds!!

alGOds

4.7K subscribers • 2 videos on Hallway

YouTube
  • Recommended by 1 person: 1 on Stack Overflow and its sister sites.
  • Presented by Vaibhav

Intermediate. Assumes working knowledge.

8.1K views6 years ago1 recommendation

Computer scienceAlgorithmsData structures

Vaibhav explains how to solve the celebrity problem in linear time using a two-pointer approach.

In this video, Vaibhav has explained the optimized approach for solving the question #TheCelebrityProblem from #GeeksForGeeks in O(n) time complexity. Question Link - practice.geeksforgeeks.org/problems/the-celebrity-problem/1 C++ Solution for Reference -- ide.geeksforgeeks.org/Ke1rfNXslF Feel free to ask any of your doubts and discuss your attempts related to this question in the comments section 😇. Join this telegram channel for regular updates : t.me/alGOdsYouTube Join this telegram group for doubts and discussions : t.me/joinchat/PqjeMhz0MBR-tg31OK2Dsg Do like and subscribe to our channel and click the bell icon so you don’t miss any future videos!!. Don’t forget to tell us about the Questions you need an explanatory video for in the comments section. We’ll definitely take care of it😁. Here is the Subscription Link : youtube.com/c/algods99 Connect with us on Gmail : algods.99@gmail.com The contributors to this channel and their profile links are enlisted below 1) Vishesh Aggarwal: LinkedIn :- linkedin.com/in/vishesh-aggarwal-830b5416b 2) Vaibhav Varshney: LinkedIn :- linkedin.com/in/vaibhav-varshney/ 3) Vagish Yagnik: LinkedIn :- linkedin.com/in/vagish-yagnik-9203b0172/ 4) Vishesh Jain: LinkedIn :- linkedin.com/in/vishesh-jain-138097174/ 5) Achint Dawra: LinkedIn :- linkedin.com/in/achint-dawra-ba9550168/ 6) V Sriram: LinkedIn :- linkedin.com/in/sriram-v-08b098170/ 7) Varun Bajlotra: LinkedIn :- linkedin.com/in/varun-bajlotra-17715a170/ 8) Vikas Yadav: LinkedIn :- linkedin.com/in/vikas-yadav-b432b5107/

Why it's here

1 person recommends this

What people say. Recommended as a clear explanation of the optimal linear-time solution to the celebrity problem.

Vaibhav Varshneyon Stack Overflow • Recommends

On “Optimal solution for the "celebrity" algorithm”

This question can be solved using graphs (indegree and outdegree concept) in O(N^2) Time complexity. We can also solve this question in O(N) time and O(1) space using a simple two-pointer concept. We are going to compare two persons at a time one from beginning and other from the end and we will remove that person from consideration which cannot be a celebrity. For example, if there are two persons X and Y and X can identify person Y then surely X cannot be a celebrity as it knows a person inside this party. Another case would be when X does not know Y and in this case, Y cannot be a celebrity as there is at least one person who does not know him/her inside a party. Using this intuition t…