Тёмный

FIND THE CELEBRITY | LEETCODE # 277 | PYTHON SOLUTION 

Cracking FAANG
Подписаться 15 тыс.
Просмотров 2,1 тыс.
50% 1

Наука

Опубликовано:

 

20 июл 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 6   
@Aaron-vi1tj
@Aaron-vi1tj Год назад
Thanks for the video. I think the intuition section could be a little more thorough in the reasoning before jumping into the approach. The key intuition comes from the problem statement: that a celebrity must not know anyone AND must be known by everyone. Thus, if you initialize a possible candidate, say A, and they know B, they are not a candidate. But there is a second half to this - why is it that if they DON'T know B, we can throw away B as an option? Because B MUST be known to be a candidate. Its obvious after reasoning it out, but tricky. Then, after one loop, what do we know? We know that the most recent candidate didn't know the portion of the people from candidateIndex to n. But we don't know if the candidate knows anyone from 0 to candidateIndex. We also don't know if EVERYONE knows the candidate. So, you must do 1 final pass.
@YT.Nikolay
@YT.Nikolay Год назад
Find an amazing youtube LC channel, hold on, I have already found it!
@lostgoat
@lostgoat Год назад
This problem is so picky with its TLE, ran into the same issue
@lostgoat
@lostgoat Год назад
I got it to pass by getting rid of the is_celeb function and merging it with findCelebrity
@crackfaang
@crackfaang Год назад
Yea Leetcode is annoying sometimes. I think they use a dynamic threshold based on like some percentile of runtime to determine the cutoffs. Funny when the official solution times out though
Далее
How I would learn Leetcode if I could start over
18:03
Просмотров 348 тыс.
Find the Celebrity
4:30
Просмотров 40 тыс.
Fast Inverse Square Root - A Quake III Algorithm
20:08
The Algorithm Behind Spell Checkers
13:02
Просмотров 408 тыс.
A* (A Star) Search Algorithm - Computerphile
14:04
Просмотров 1,1 млн
Красиво, но телефон жаль
0:32
Просмотров 1,3 млн
Я УКРАЛ ТЕЛЕФОН В МИЛАНЕ
9:18
Просмотров 126 тыс.