The Celebrity Problem | GFG | GFG POTD | Java & C++ code | 30-08-2025
Автор: codefou
Загружено: 2025-08-29
Просмотров: 243
In this video, we solve the Celebrity Problem – a popular coding interview question.
A celebrity at a party is defined as someone who is known by everyone but does not know anyone else.
Solution :
Two Pointer : https://github.com/Codefou01/GFG-POTD...
Stack : https://github.com/Codefou01/GFG-POTD...)
We are given an n x n matrix mat[][] where:
mat[i][j] = 1 → person i knows person j
mat[i][j] = 0 → person i does not know person j
mat[i][i] = 1 (self-knowledge is always set)
👉 The task is to find the index of the celebrity, or return -1 if no celebrity exists.
We discuss the optimal O(n) two-pointer approach along with the verification step to ensure correctness.
This problem is commonly asked in interviews and coding platforms like GeeksforGeeks and LeetCode (Find the Celebrity - Problem 277).
✨ Topics Covered:
Problem Explanation with Examples
Naive Approach vs Optimized Approach
Two-Pointer Elimination Method
Time & Space Complexity Analysis
Don't forget to like, comment, and subscribe if this helped you!
Share with your friends preparing for interviews😊
#coding #youtube #programming #dsa #gfg #leetcode #interview #technical #codinginterview #java #C++
Доступные форматы для скачивания:
Скачать видео mp4
-
Информация по загрузке: