Reallly , my search for a good and clear explanation ends here! Thank u 900!
@techcourses4u Жыл бұрын
Thanks and Welcome 3000!!!
@552sonalprasad9 Жыл бұрын
I love your explanation.. keep making videos . I really need institutions of each question deeply .
@techcourses4u Жыл бұрын
Thank you, I will
@rajivkoiri120 күн бұрын
Seedhi baat no bakwas😀 Good one bro 👌
@techcourses4u20 күн бұрын
Thanks!!!
@thisismr900 Жыл бұрын
I have a doubt Here vectoradj(n) see,a node can have multiple neighbours How can u track them using this vector
@thisismr900 Жыл бұрын
Shouldnt it be vectoradj
@techcourses4u Жыл бұрын
vector adj[n]; This is syntax for array of vectors. This representation means an array of size n whose each element is a vector. Like we have array of ints where each array element will store an integer. Here we have an array of vectors i.e. each element will store a vector (for multiple neighbours). Alternatively, you can think of it as a 2D vector where 1st dimension is fixed as n and second dimension is variable.
@thisismr900 Жыл бұрын
class Solution { private: long long dfs( int currNode, int prevNode,int &splits,vector&adj,vector& values, int k){ long long nodeVal=values[currNode]; //visit the neighbours other than prevNode for(auto neighbour:adj[currNode]){ if(neighbour != prevNode) nodeVal+= dfs(neighbour, currNode,splits, adj, values, k); } if(nodeVal % k == 0){ splits++; return 0; } return nodeVal; } public: int maxKDivisibleComponents(int n, vector& edges, vector& values, int k) { vectoradj(n); for(auto e:edges){ adj[e[0]].push_back(e[1]); adj[e[1]].push_back(e[0]); } //run dfs from node 0 int splits=0; dfs(0,-1,splits,adj,values,k); return splits; } }; This works perfectly fine But with the syntax mentioned in video it gives error ,for obvious reasons@@techcourses4u