Reorder Routes to Make All Paths Lead to the City Zero || Graphs || DFS

  Рет қаралды 4,791

Aryan Mittal

Aryan Mittal

Күн бұрын

Пікірлер: 16
@ARYANMITTAL
@ARYANMITTAL Жыл бұрын
C++/Java/Python Code & Notes: drive.google.com/file/d/1QCMV_ClrPWZWKDznTAqjTVwwP7Q4N78h/view?usp=sharing
@akshatsingh9011
@akshatsingh9011 6 ай бұрын
This same question I encountered in the coding round of MIcrosoft for my on-campus placement
@utkarshsharma1185
@utkarshsharma1185 Жыл бұрын
Thanks aryan bhaiya for the nice and clear explanation
@SouravKumar-rg4yj
@SouravKumar-rg4yj Жыл бұрын
keep this good work please...really helpful for many people.. thanks a lot man❤
@kunalsabadra6802
@kunalsabadra6802 Жыл бұрын
Nice explanation bro 🔥❤‍🔥
@girikgarg8
@girikgarg8 Жыл бұрын
Nice explanation
@oqant0424
@oqant0424 Жыл бұрын
thanks Aryan!
@geeteshyadav12
@geeteshyadav12 Жыл бұрын
Keep it up
@k.k.harjeeth5422
@k.k.harjeeth5422 9 ай бұрын
from collections import defaultdict class Solution: def minReorder(self, n: int, connections: List[List[int]]) -> int: edges=set() for i in connections: edges.add(tuple(i)) neighbors=defaultdict(list) for a,b in connections: neighbors[a].append(b) neighbors[b].append(a) visited=set() count=0 def dfs(city): nonlocal count visited.add(city) for i in neighbors[city]: if(i not in visited and (i,city) not in edges): count+=1 dfs(i) elif(i not in visited): dfs(i) dfs(0) return count
@stuartYoung559
@stuartYoung559 Жыл бұрын
change += dfs(gr, visited, abs(to)) + (to > 0); i have seen this kind of syntax for very first time, can anyone explain me this to>0 , i tried to give if condition above dfs call , but answer coming was not correct like if(t>0)change++; dfs(,,);
@ok-google-run
@ok-google-run Жыл бұрын
I think its like conditioning and getting value 1 or 0
@angajalasaisri8228
@angajalasaisri8228 Жыл бұрын
Bro In thumbnail the Question name written wrong. Instead of "reorder" there is "record."
@ARYANMITTAL
@ARYANMITTAL Жыл бұрын
Thanks broo 🙌🏻
@girishgarg2816
@girishgarg2816 Жыл бұрын
Same Aryan from 2y ago but richer.
@rishipalsingh9404
@rishipalsingh9404 Жыл бұрын
bro be simple , itna tough code se samjhna is not good. just stick to the basic syntax of c++ like babbar bhaiya, anuj bhaiya etc. cool banke kuch fayda nh try to help us.
@AshutoshChoudhary2004
@AshutoshChoudhary2004 Жыл бұрын
Bhai bhot simple hi samjhya hai code pehle basic c++ strong karle fir kar lena DSA
Ozoda - Alamlar (Official Video 2023)
6:22
Ozoda Official
Рет қаралды 10 МЛН
She wanted to set me up #shorts by Tsuriki Show
0:56
Tsuriki Show
Рет қаралды 8 МЛН
Find if Path Exists in Graph - Leetcode 1971 - Graphs (Python)
12:20
Writing My Own Database From Scratch
42:00
Tony Saro
Рет қаралды 267 М.
NVIDIA CEO Jensen Huang's Vision for Your Future
1:03:03
Cleo Abram
Рет қаралды 279 М.
How to Remember Everything You Read
26:12
Justin Sung
Рет қаралды 3,2 МЛН
Making an Algorithm Faster
30:08
NeetCodeIO
Рет қаралды 204 М.
Ozoda - Alamlar (Official Video 2023)
6:22
Ozoda Official
Рет қаралды 10 МЛН