Maximum Number of K Divisible Components | Leetcode 2872

  Рет қаралды 5,490

Techdose

Techdose

Күн бұрын

Пікірлер: 48
@utsavjha9236
@utsavjha9236 19 күн бұрын
You are a great teacher, one of the best i have seen.
@techdose4u
@techdose4u 19 күн бұрын
thanks for your appreciation
@kheersagarpatel3195
@kheersagarpatel3195 19 күн бұрын
Yes sir, your teaching is just awesome, i have got new enthusiasm for the DSA and i hope i will surely reach my dream destination by following you..
@techdose4u
@techdose4u 19 күн бұрын
If DSA is the path to your destination then I guarantee you will be posting your success story with me in future here :)
@kheersagarpatel3195
@kheersagarpatel3195 19 күн бұрын
@techdose4u waiting for that day and working for that day from my heart sir ..... I am also your linkedin connection i hope you recognised me....
@techdose4u
@techdose4u 19 күн бұрын
definitely let me know if I can help you :)
@baka_man2512
@baka_man2512 21 күн бұрын
Thanks sir for this consistency 🙏
@techdose4u
@techdose4u 21 күн бұрын
Consistency is the key 🔑:)
@LinhHoang-ml1qo
@LinhHoang-ml1qo 21 күн бұрын
Literally, your explaination is very good. You slolved the complex problem using the simple concept and standard in greedy approach.This make me eassyly to get the idea to solve this.Thank you, teacher!
@techdose4u
@techdose4u 20 күн бұрын
welcome :)
@kky7811
@kky7811 21 күн бұрын
Great Explanation . Thanks for ur Effort 😎😎.
@techdose4u
@techdose4u 21 күн бұрын
welcome :)
@sailendrachettri8521
@sailendrachettri8521 21 күн бұрын
today i participated in biweekly LC contest and was able to solve 1 question :)
@techdose4u
@techdose4u 21 күн бұрын
great :) you will improve slowly. keep up your good work
@sailendrachettri8521
@sailendrachettri8521 20 күн бұрын
@@techdose4u sure sir :)
@Princekumar-ty4qp
@Princekumar-ty4qp 21 күн бұрын
Consistency🔥
@techdose4u
@techdose4u 20 күн бұрын
:)
@AmarjeetKumar-to9ub
@AmarjeetKumar-to9ub 21 күн бұрын
Ty sir :)
@techdose4u
@techdose4u 20 күн бұрын
Welcome :)
@chandanaarvapally
@chandanaarvapally 21 күн бұрын
@techdose sir, i am getting tle for the above code? what to do?
@kiran1379
@kiran1379 20 күн бұрын
Check if you are passing values by reference or not
@techdose4u
@techdose4u 20 күн бұрын
Please check your recursion break condition & reference pass as mentioned :)
@gireeswar18
@gireeswar18 21 күн бұрын
Thank you sir. How to think about the solution like you sir? I feel stuck on seeing this problem.
@techdose4u
@techdose4u 21 күн бұрын
Practice the key :)
@ENUMARTHYGNYANAPRASUNA
@ENUMARTHYGNYANAPRASUNA 21 күн бұрын
​@@techdose4ufor this question what relevant topics should be practiced sir?
@Anikait-h3d
@Anikait-h3d 21 күн бұрын
can you also start solving leetcode contest questions. It would really help all of us
@indianofficialclashers9148
@indianofficialclashers9148 21 күн бұрын
Sir please explain the illustration you draw and the code side by side because many times what happens is beginners like me can't associate the two So it would be really helpful if you tell us which line of code corresponds to which illustration 🙂
@techdose4u
@techdose4u 21 күн бұрын
Many people might find it too boring hence avoiding that to manage within limited time :)
@gireeswar18
@gireeswar18 21 күн бұрын
In java code we can use a static variable and init with 0 on every call, this avoids using an array to store count.
@techdose4u
@techdose4u 21 күн бұрын
same can be done in c++ using static :)
@gireeswar18
@gireeswar18 21 күн бұрын
@techdose4u yes sir 😊
@indianofficialclashers9148
@indianofficialclashers9148 21 күн бұрын
In the dfs function , where does the recursion end and start going back ?
@techdose4u
@techdose4u 21 күн бұрын
recursion starts with exploring all adjancent edges and ends when loop ends after exploration is done
@crazygamerrohan9899
@crazygamerrohan9899 21 күн бұрын
if i am passing the adj vector by valyue then it is showing me time limit exceed why??
@techdose4u
@techdose4u 21 күн бұрын
I had mentioned in the video about integer overflow. The return type of dfs needs to be set to 64-bit integer. Ex. Long Long dfs()
@ASHUTOSHSHARMA-us6hd
@ASHUTOSHSHARMA-us6hd 21 күн бұрын
@@techdose4u fir bhi tle aa rha hai, sir ji
@ASHUTOSHSHARMA-us6hd
@ASHUTOSHSHARMA-us6hd 21 күн бұрын
@@techdose4u class Solution { public: long long dfs(long long node, vector adj, vector& vals, int k, long long & counter, long long parent) { long long sum = vals[node]; for (auto negh : adj[node]) { if (negh != parent) { sum += dfs(negh, adj, vals, k, counter, node); } } sum%=k; if(sum==0) counter++; return sum; } int maxKDivisibleComponents(int n, vector& edges, vector& vals, int k) { long long counter = 0; vector adj(n); for (auto it : edges) { int firstNode = it[0]; int SecondNode = it[1]; adj[firstNode].push_back(SecondNode); adj[SecondNode].push_back(firstNode); } dfs(0, adj, vals, k, counter, -1); return counter; } };
@ASHUTOSHSHARMA-us6hd
@ASHUTOSHSHARMA-us6hd 21 күн бұрын
@@techdose4u this code is giving tle, what to do??
@crazygamerrohan9899
@crazygamerrohan9899 20 күн бұрын
@@techdose4u means if iam passing vector as values then it requires stack space but in case of passing by reference it does not require stack space??
@Anikait-h3d
@Anikait-h3d 21 күн бұрын
ab lagta hai agle week tak trees and bfs ke upar hi question ayga
@techdose4u
@techdose4u 21 күн бұрын
😂
@AmitDaily_Vlogs
@AmitDaily_Vlogs 21 күн бұрын
sir aap robot ho kya explanation tora expressive bana skte ho kya
@techdose4u
@techdose4u 21 күн бұрын
If I make expressive then my sound quality will reduce. Good mic is costly hence just managing for my resources at hand :)
@AmitDaily_Vlogs
@AmitDaily_Vlogs 21 күн бұрын
@techdose4u okay sir you are doing great work and it was just a feedback 😁😁
@techdose4u
@techdose4u 21 күн бұрын
Yea I too realised that but waiting for collecting some amount for it then will change mic:)
Count Ways To Build Good Strings | Leetcode 2466
18:35
Techdose
Рет қаралды 1,4 М.
人是不能做到吗?#火影忍者 #家人  #佐助
00:20
火影忍者一家
Рет қаралды 20 МЛН
Quando A Diferença De Altura É Muito Grande 😲😂
00:12
Mari Maria
Рет қаралды 45 МЛН
Beat Ronaldo, Win $1,000,000
22:45
MrBeast
Рет қаралды 158 МЛН
We Attempted The Impossible 😱
00:54
Topper Guild
Рет қаралды 56 МЛН
one year of studying (it was a mistake)
12:51
Jeffrey Codes
Рет қаралды 128 М.
Dynamic Programming isn't too hard. You just don't know what it is.
22:31
DecodingIntuition
Рет қаралды 236 М.
What is an object pool, and how to create one in C?
23:14
Jacob Sorber
Рет қаралды 12 М.
Construct K Palindrome Strings | Leetcode 1400
12:17
Techdose
Рет қаралды 1,4 М.
I Solved 100 LeetCode Problems
13:11
Green Code
Рет қаралды 303 М.
Making an Algorithm Faster
30:08
NeetCodeIO
Рет қаралды 194 М.
before you code, learn how computers work
7:05
Low Level
Рет қаралды 596 М.
人是不能做到吗?#火影忍者 #家人  #佐助
00:20
火影忍者一家
Рет қаралды 20 МЛН