LONGEST PATH WITH DIFFERENT ADJACENT CHARACTERS | LEETCODE 2246 | PYTHON DFS SOLUTION

  Рет қаралды 2,616

Cracking FAANG

Cracking FAANG

Күн бұрын

JOIN OUR DISCORD COMMUNITY: / discord
In this video we are solving a Hard level Microsoft interview question dealing with graphs: Longest Path with Different Adjacent Characters (Leetcode 2246).
This question is actually not that hard for a hard level question, it really should be more of a medium. I'm not sure why it's rated a hard when there are medium tree questions that are more difficult. It's one of those problems where you need to build a graph from some input and then perform a traversal on that graph to get the final solution.
TIMESTAMPS
00:00 Intro
00:20 Question Prompt
01:05 Basic Example
02:35 Solution Intuition
06:20 Coding
10:28 Time/Space Complexity
11:15 Outro

Пікірлер: 17
@laumatthew71
@laumatthew71 Жыл бұрын
Very clear explanation on the algorithm, thank you ! One thing to add potentially in the video is a run through of the algorithm on a particular example, this may help visualize the algorithm more clearly :)
@sak4531
@sak4531 Жыл бұрын
Dude you are pretty Good!! I think you are on the same levels of NeetCode (another youtuber). DON'T STOP MAKING VIDEOS!!
@YT.Nikolay
@YT.Nikolay Жыл бұрын
It's gonna be long path :) thanks for the video!
@MP-ny3ep
@MP-ny3ep Жыл бұрын
Thank you awesome solution
@subee128
@subee128 5 ай бұрын
Thank you
@rsKayiira
@rsKayiira Жыл бұрын
thank you for the video
@keerthivasan138
@keerthivasan138 Жыл бұрын
The Hard Part is figuring out to calculate two paths at each node and updating the result and only passing the longest one to the parent(which is not intutive for me) thanks for your video explanation
@azirettoktoraliev1645
@azirettoktoraliev1645 Жыл бұрын
thank you man, hope you aren't going to vanish like other youtubers do
@crackfaang
@crackfaang Жыл бұрын
I hope more people watch so I have a reason to make videos 😂
@skyacaniadev2229
@skyacaniadev2229 Жыл бұрын
My answer feels like crap comparing to yours. Got so much to learn from you. 😂
@CostaKazistov
@CostaKazistov Жыл бұрын
Good explanation. White background for code editor is a terrible choice though. It is so much more pleasant to code on a dark theme background.
@GunalanDeivaganpathy
@GunalanDeivaganpathy Жыл бұрын
intuition is not clear tbh
@bouzie8000
@bouzie8000 4 ай бұрын
This largest, second largest intuition isn't making sense to me. I assumed we'd be able to solve this by thinking each node would implicitly store its max length. And then we'll have the condition that checks whether the child node == parent node. If not, we add the length and then check for the max and store it. But everyone's solution online seems to be working with computing a 'second largest' length which is confusing to me
@bouzie8000
@bouzie8000 4 ай бұрын
Ahh I've come up with my rationale for it: We are not concerned with the node itself (except when we're checking if it's equal to the parent), but more so the edge count. So each node can have an implicit max path associated with it (which can be child a->node itself->child b). To know which two children are involved in this max path, it will definitely have to be the child with the associated longest path and the child with the associated second longest path
@danianiazi8229
@danianiazi8229 Жыл бұрын
can someone please explain the working and swapping of longes ans second longest
@crackfaang
@crackfaang Жыл бұрын
Say longest is 5, and second longest is 2. Now you receive a path length of 10. The longest is now 10, and the second longest is now the old longest (5). But let's say you had 5 as the longest, 2 as the second longest again and now you receive a path length of 3. Longest is still 5, but second longest is now 3.
@bostonlights2749
@bostonlights2749 Жыл бұрын
Comment for better reach
THEY made a RAINBOW M&M 🤩😳 LeoNata family #shorts
00:49
LeoNata Family
Рет қаралды 34 МЛН
1 or 2?🐄
00:12
Kan Andrey
Рет қаралды 52 МЛН
КАРМАНЧИК 2 СЕЗОН 7 СЕРИЯ ФИНАЛ
21:37
Inter Production
Рет қаралды 536 М.
LONGEST INCREASING PATH IN A MATRIX | PYTHON | LEETCODE # 329
13:10
Cracking FAANG
Рет қаралды 1,2 М.
Day 10 - Solving LeetCode Problems Until FAANG Hires Me
7:12
Robotaxis | Big Ideas 2024
9:41
ARK Invest
Рет қаралды 58 М.
VERIFYING AN ALIEN DICTIONARY | LEETCODE 953 | PYTHON SOLUTION
13:20
BEST MEETING POINT | LEETCODE 296 | PYTHON OPTIMAL SOLUTION
18:06
Cracking FAANG
Рет қаралды 1,6 М.
Implement Trie (Prefix Tree) - Leetcode 208
18:56
NeetCode
Рет қаралды 180 М.
Clicks чехол-клавиатура для iPhone ⌨️
0:59
Игровой Комп с Авито за 4500р
1:00
ЖЕЛЕЗНЫЙ КОРОЛЬ
Рет қаралды 2,1 МЛН
iPhone 15 Pro в реальной жизни
24:07
HUDAKOV
Рет қаралды 204 М.