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

  • @soumabhaghosh6199
    @soumabhaghosh61994 ай бұрын

    Love U Aryan Mutthal

  • @ankitraj2283
    @ankitraj22834 ай бұрын

    16:46 This two Balls 🫡

  • @ARINCHOUDHARY
    @ARINCHOUDHARY4 ай бұрын

    so much effort, it so great to see someone putting that hardwork to make lives easier

  • @TrungPham-rr3jb
    @TrungPham-rr3jb4 ай бұрын

    perfect explanation, thanks

  • @obamaengineer4806
    @obamaengineer48064 ай бұрын

    goated explanation. will be a hit yt channel soon

  • @sukhpreetsingh5200
    @sukhpreetsingh52004 ай бұрын

    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

  • @Sumeet_100
    @Sumeet_1004 ай бұрын

    You are too good man !! Keep it up brother !!

  • @ganeshmula4508
    @ganeshmula45084 ай бұрын

    Thank you

  • @manjeetyadav5830
    @manjeetyadav58304 ай бұрын

    your are the best for me!

  • @priyanshu6173
    @priyanshu61734 ай бұрын

    Thnx bro well explained

  • @giridharanpasupathi
    @giridharanpasupathi4 ай бұрын

    TQ bro❤

  • @alokgautam02
    @alokgautam024 ай бұрын

    thnx bro , for such detailed explanation .

  • @shameekagarwal4872
    @shameekagarwal48724 ай бұрын

    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?

  • @asthajain2511
    @asthajain25114 ай бұрын

    You are great sir !!!

  • @user-tj8xi4xi8k
    @user-tj8xi4xi8k4 ай бұрын

    epic explanation

  • @user-dx2dd2kk9o
    @user-dx2dd2kk9o4 ай бұрын

    bro i solved this question using warshall but its giving tle......but generally on leetcode n cube is acceptable for 10^3

  • @umeshhbhat

    @umeshhbhat

    4 ай бұрын

    warshall is cubic. so TC will come around 10^9, anything above 10^8 will give TLE

  • @GYANKIBAAT-ze7nd
    @GYANKIBAAT-ze7nd4 ай бұрын

    First ✋✋

  • @tentx652
    @tentx6524 ай бұрын

    great work bro

  • @ARYANMITTAL

    @ARYANMITTAL

    4 ай бұрын

    Thank you so much 😀❤️❤️

  • @mohneeshgarg8706
    @mohneeshgarg87064 ай бұрын

    I too did with the same approach, but I got TLE in the contest

  • @dumpster-jackson

    @dumpster-jackson

    4 ай бұрын

    same here

  • @mukulkhanna5071
    @mukulkhanna50714 ай бұрын

    aryan bhai mera to abhi bhi tle arrha hai same code par bhi and during the contest par aa rha tha

  • @mukulkhanna5071
    @mukulkhanna50714 ай бұрын

    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

  • @satwiktatikonda764
    @satwiktatikonda76429 күн бұрын

    floyd warshall

  • @pratyush2331raj
    @pratyush2331raj4 ай бұрын

    27:07 😂😂

  • @39_jatinjain4
    @39_jatinjain44 ай бұрын

    I knew the intuition but didn't implement it because of - O(V^2 * (V + E)) Time complexity why it is accepted??

  • @thomasshelby6780

    @thomasshelby6780

    4 ай бұрын

    it must be v2 only

  • @39_jatinjain4

    @39_jatinjain4

    4 ай бұрын

    How??

  • @fraserdab
    @fraserdab4 ай бұрын

    Nahi aaya mujhe ye question

  • @__hello__world__11
    @__hello__world__114 ай бұрын

    8:20 ping 999+ms🤣🤣🤣🤣

Келесі