3067. Count Pairs of Connectable Servers in a Weighted Tree Network | Graph | DFS | Math
In this video, I'll talk about how to solve Leetcode 3067. Count Pairs of Connectable Servers in a Weighted Tree Network | Graph | DFS | Math
Checkout DSA-169 Series: • Aryan DSA-169 Series |...
100Days 100k Placements: • 100 Days 100K Placement
Let's Connect:
📝Linkedin: / aryan-mittal-0077
📸 Instagram: / ez.pz.dsa
📱Telegram : t.me/aryan_mittal_group
🤖 Github: github.com/aryan-0077
About Me:
I am Aryan Mittal - A Software Engineer in Goldman Sachs, Speaker, Creator & Educator. During my free time, I create programming education content on this channel & also how to use that to grow :)
✨ Timelines✨
✨ Hashtags ✨
#programming #Interviews #leetcode #faang #maang #datastructures #algorithms
Пікірлер: 31
Love U Aryan Mutthal
16:46 This two Balls 🫡
so much effort, it so great to see someone putting that hardwork to make lives easier
perfect explanation, thanks
goated explanation. will be a hit yt channel soon
I solved this using bfs but I had to use one more variable which will keep track of different paths for a particular node. class Solution { public: vector countPairsOfConnectableServers(vector& edges, int signalSpeed) { int n=edges.size(); vectoradj[n+1]; for(auto it:edges){ adj[it[0]].push_back({it[1],it[2]}); adj[it[1]].push_back({it[0],it[2]}); } vectorresult; for(int i=0;i0){ tp.push_back(it.first); kl--; } } } int resu=0; for(int i=0;i
You are too good man !! Keep it up brother !!
Thank you
your are the best for me!
Thnx bro well explained
TQ bro❤
thnx bro , for such detailed explanation .
hi aryan - the trick that u used to solve for avoiding an n^2 loop for components I did not use that trick, but did not get a tle for my submission how is it possible? i think that the worst case is "star graph" - all these components will be multiplied with each other but, advantage is it will happen for only one node, not all n nodes in the star graph but still, how do I prove this?
You are great sir !!!
epic explanation
bro i solved this question using warshall but its giving tle......but generally on leetcode n cube is acceptable for 10^3
@umeshhbhat
4 ай бұрын
warshall is cubic. so TC will come around 10^9, anything above 10^8 will give TLE
First ✋✋
great work bro
@ARYANMITTAL
4 ай бұрын
Thank you so much 😀❤️❤️
I too did with the same approach, but I got TLE in the contest
@dumpster-jackson
4 ай бұрын
same here
aryan bhai mera to abhi bhi tle arrha hai same code par bhi and during the contest par aa rha tha
class Solution { private: int ss,ct; void dfs(int node,int par,int d, unordered_map&gr){ if(d%ss==0)ct++; for(auto [ch,dis]:gr[par]){ if(ch!=par){ dfs(ch,node,dis+d,gr); } } } public: vector countPairsOfConnectableServers(vector& edges, int signalSpeed) { int n=edges.size()+1; ss=signalSpeed; unordered_mapgr; for(auto vec:edges){ int u=vec[0],v=vec[1],d=vec[2]; gr[u].push_back({v,d}); gr[v].push_back({u,d}); } vectorfans(n,0); for(int par=0;par
floyd warshall
27:07 😂😂
I knew the intuition but didn't implement it because of - O(V^2 * (V + E)) Time complexity why it is accepted??
@thomasshelby6780
4 ай бұрын
it must be v2 only
@39_jatinjain4
4 ай бұрын
How??
Nahi aaya mujhe ye question
8:20 ping 999+ms🤣🤣🤣🤣