Minimum Score of a Path Between Two Cities - Leetcode 2492 - Python

preview_player
Показать описание

Solving Leetcode 2492 - Minimum Score of a Path Between Two Cities, today's daily leetcode problem on March 21st.

0:00 - Read the problem
0:40 - Drawing Explanation
3:40 - Coding Explanation

leetcode 2492

#neetcode #leetcode #python
Рекомендации по теме
Комментарии
Автор

So in very simple term: we get the minimum distance of every road in the cluster that have city 1?

picnicbros
Автор

Great explanation.
Silly question. This questions should not exist.

DavidDLee
Автор

I had same issue with non local that you can use a list outside function but not a variable.

SarveshRansubhe
Автор

Could we just loop over the roads array and choose the minimum roads[i][2] value ? :)

Just tried it and it did not go trough time constraints, but we still do it with O (N), so why this approach did not work ?)

kirillzlobin
Автор

You are the best!!! Thank you very much!

michaelsu
Автор

Is it not the same as getting the minimum value of the distance field from the list? i.e return min([z for _, _, z, in roads])
I know it fails a test case, but looking at the dfs code, I fail to see the difference.

pixiedust
Автор

Please make a video on "Sort Items by Groups Respecting Dependencies"

handsomeabu
Автор

Why won't the approach of simply finding the minimum edge weight work for all cases when determining the minimum score of a path between two cities?

VikashKumar-wrhv
Автор

If we want to find the minimum weight or distance then why can't we run a for loop on roads and get the minimum distance out of it?

sourin.majumdar
Автор

would this also work by updating res right after you add each node to the visited set?

julianelmasry
Автор

Our timing for solving leetcode is same, I literally just solved and you posted video

nizarkadri
Автор

what?? Are you here? I mean you have another channel. Why did you create another one?? Any specific reason? BTW I am also from INDIA. I am still in high school and currently I am way too confused. I am pretty good at coding but still i see a lot of friends preparing JEE exam. I am not sure if i should continue my passion or not. I mean I don't know if I focus on exam (which is next year btw) or solving leetcode.
Anyways your videos mean a lot to me and the fact you are from India is just '"wow"

sickboydroid