Number of Nodes in the Sub-Tree With the Same Label : (Better Approach) | Explanation ➕ Live Coding

Subscribers:
92,300
Published on ● Video Link: https://www.youtube.com/watch?v=yZ6IM8Q-0Ac



Duration: 27:38
280 views
26


This is the 11th Video on our Graph Playlist.
In this video we will try to solve the Graph problem "Number of Nodes in the Sub-Tree With the Same Label" with a better approach.
We solved it in our 10th video of our playlist. We will do an optimization of our approach in this video.

If you have been following my "Graph Concepts & Qns" playlist , then these Qns will become very easy because all we have to do is just Traverse the graph.
So, just write DFS and apply logic(story) as per the question

Problem Name : Number of Nodes in the Sub-Tree With the Same Label
Company Tags : soon
My solutions on Github : https://github.com/MAZHARMIK/Interview_DS_Algo/blob/master/Graph/Number%20of%20Nodes%20in%20the%20Sub-Tree%20With%20the%20Same%20Label.cpp
Leetcode Link : https://leetcode.com/problems/number-of-nodes-in-the-sub-tree-with-the-same-label/


My Graph Concepts Playlist : https://www.youtube.com/watch?v=5JGiZnr6B5w&list=PLpIkg8OmuX-LZB9jYzbbZchk277H5CbdY
My GitHub Repo for interview preparation : https://github.com/MAZHARMIK/Interview_DS_Algo
Subscribe to my channel : https://www.youtube.com/channel/UCaw58edcO3ZqMw76Bvs0kGQ

0:00 - Intro and Recap
0:54 - Why this is a better approach ?
6:51 - Intuition Building
9:39 - (Story) Understand with a dry run
21:02 - Live Coding from Story

╔═╦╗╔╦╗╔═╦═╦╦╦╦╗╔═╗
║╚╣║║║╚╣╚╣╔╣╔╣║╚╣═╣
╠╗║╚╝║║╠╗║╚╣║║║║║═╣
╚═╩══╩═╩═╩═╩╝╚╩═╩═╝

#coding #helpajobseeker #easyrecipes #leetcode #leetcodequestionandanswers #leetcodesolution #leetcodedailychallenge #leetcodequestions #leetcodechallenge #hindi #india #hindiexplanation #hindiexplained #easyexplaination #interview #interviewtips
#interviewpreparation #interview_ds_algo #hinglish




Other Videos By codestorywithMIK


2023-01-17Flip String to Monotone Increasing - (GOOGLE) | Optimal | Explanation ➕ Live Coding
2023-01-17Flip String to Monotone Increasing - (GOOGLE) | Recursion+Memo | Explanation ➕ Live Coding
2023-01-16Insert Interval (Google, Twitter, Microsoft, Apple, Amazon) : Explanation ➕ Live Coding
2023-01-15Number of Good Paths | GOOGLE | DSU | Explanation ➕ Live Coding
2023-01-15Disjoint Set Union By Rank and Path Compression - | DSU | Graph Concepts & Qns -19| Explanation+Code
2023-01-15Disjoint Set Union - | DSU | Graph Concepts & Qns - 18 | Explanation+Coding
2023-01-15Is Graph Bipartite ? - (Facebook, Microsoft) | BFS | Graph Concepts & Qns - 17 | Explanation+Coding
2023-01-14Is Graph Bipartite ? - (Meta, Microsoft..) | DFS | Graph Concepts & Qns - 16 | Explanation+Coding
2023-01-14Lexicographically Smallest Equivalent String | DFS | Explanation ➕ Live Coding
2023-01-12Longest Path With Different Adjacent Characters : (Microsoft) | Explanation ➕ Live Coding
2023-01-12Number of Nodes in the Sub-Tree With the Same Label : (Better Approach) | Explanation ➕ Live Coding
2023-01-12Number of Nodes in the Sub-Tree With the Same Label : Explanation ➕ Live Coding
2023-01-11Course Schedule-II - (Apple,Microsoft,Amazon) | DFS | Graph Concepts & Qns - 15 | Explanation+Coding
2023-01-10Minimum Time to Collect All Apples in a Tree - (Microsoft) : Explanation ➕ Live Coding
2023-01-10Course Schedule - (Apple, Microsoft,Amazon) | DFS | Graph Concepts & Qns - 14 | Explanation+Coding
2023-01-09Same Tree - (Google, Adobe, Meta, Amazon, Uber, Bloomberg) : Explanation ➕ Live Coding
2023-01-09Course Schedule-II : (Apple, Microsoft,Amazon) | BFS | Graph Concepts & Qns - 13 |Explanation+Coding
2023-01-09Binary Tree Preorder Traversal - (Microsoft, Walmart, Flipkart, Amazon) : Explanation ➕ Live Coding
2023-01-08Course Schedule - (Apple, Microsoft,Amazon) | BFS | Graph Concepts & Qns - 12 | Explanation+Coding
2023-01-08Max Points on a Line -(Google, Apple, LinkedIn, Amazon) : Explanation ➕ Live Coding
2023-01-06Gas Station (Google, Amazon, Uber, Microsoft, FactSet, Zoho, Flipkart) : Explanation ➕ Live Coding