2.94K subscribers
7 photos
4 files
237 links
This channel is all about programming. Happy coding :)
Download Telegram
Day-2:
Course Schedule-2: https://leetcode.com/problems/course-schedule-ii/
Leetcode #210

Please go through the algorithm from the link below (Please don’t watch the course schedule part in the 2nd half of the video without solving yourself 🙂 )
Algorithm: Topological Sort -> https://youtu.be/qe_pQCh09yU
Solution will be shared tomm evening followed by a new question 🙂

#30DaysOfGraph #techdose #interviewpreparation #graphs #dsa
Above problem is for Day-6 🙂
Day-6: Solution
Number of Provinces
Leetcode #547

Algorithm: Disjoint Set
Code Implementation: https://gist.github.com/SuryaPratapK/fe865b1680aceda9594a5160f80fb870
Video for Disjoint Set (Union & Find): https://youtu.be/eTaWFhPXPz4
Video for Disjoint Set (Union by RANK & Find->Path Compression): https://youtu.be/kaBX2s3pYO4

Logic:-
1 Use disjoint set to add all edges
2 DSUF array will have -1 value for only absolute parents
3 No of -1 = No of absolute parents = No of components (because all absolute parents belongs to different tree, hence different components 🙃 )

Please go through the video to understand Disjoint Set and then implement in the problem 🙂



#30DaysOfGraph #techdose #interviewpreparation #graphs #dsa
Day-7: Solution
Evaluate Division
Leetcode #399

Algorithm: Disjoint Set
SOLUTION code: https://gist.github.com/SuryaPratapK/b4ea37a86814d08856b4cd4ef41c640f
Video for Disjoint Set (Union & Find): https://youtu.be/eTaWFhPXPz4
Video for Disjoint Set (Union by RANK & Find->Path Compression): https://youtu.be/kaBX2s3pYO4

LOGIC:
1 Build a bidirectional graph with weight as: (If a=4 and b=2 then, a->b (edge wt=4/2) and b->a (edge wt=2/4))
2 For any given a/c, start traversing from a and try reaching c (a/b * b/c = a/c). Keep multiplying values while traversing.


Please go through the video to understand Disjoint Set and then implement in the problem 🙂


#30DaysOfGraph #techdose #interviewpreparation #graphs #dsa