Day-3:
All Paths From Source to Target:
https://leetcode.com/problems/all-paths-from-source-to-target/
Leetcode #797
Algorithm: DFS
Video for DFS: https://youtu.be/CvUMf8c2JFo
Please go through the video to understand DFS and then implement in the problem 🙂
Solution will be shared tomm evening 🙂
#30DaysOfGraph #techdose #interviewpreparation #graphs #dsa
All Paths From Source to Target:
https://leetcode.com/problems/all-paths-from-source-to-target/
Leetcode #797
Algorithm: DFS
Video for DFS: https://youtu.be/CvUMf8c2JFo
Please go through the video to understand DFS and then implement in the problem 🙂
Solution will be shared tomm evening 🙂
#30DaysOfGraph #techdose #interviewpreparation #graphs #dsa
LeetCode
All Paths From Source to Target - LeetCode
Can you solve this real interview question? All Paths From Source to Target - Given a directed acyclic graph (DAG) of n nodes labeled from 0 to n - 1, find all possible paths from node 0 to node n - 1 and return them in any order.
The graph is given as follows:…
The graph is given as follows:…
Day-3: Solution
All Paths From Source to Target (Topological Sort):
https://leetcode.com/problems/all-paths-from-source-to-target/
Leetcode #797
Algorithm: DFS
Video for DFS: https://youtu.be/CvUMf8c2JFo
Please go through the video to understand DFS and then implement in the problem 🙂
Solution CODE: https://gist.github.com/SuryaPratapK/ae74fe725299479eca9ed45a02680941
STEPS:-
1 Make adjacency-list
2 Find all possible paths using DFS (by maintaining current path in stack or array)
#30DaysOfGraph #techdose #interviewpreparation #graphs #dsa
All Paths From Source to Target (Topological Sort):
https://leetcode.com/problems/all-paths-from-source-to-target/
Leetcode #797
Algorithm: DFS
Video for DFS: https://youtu.be/CvUMf8c2JFo
Please go through the video to understand DFS and then implement in the problem 🙂
Solution CODE: https://gist.github.com/SuryaPratapK/ae74fe725299479eca9ed45a02680941
STEPS:-
1 Make adjacency-list
2 Find all possible paths using DFS (by maintaining current path in stack or array)
#30DaysOfGraph #techdose #interviewpreparation #graphs #dsa
LeetCode
All Paths From Source to Target - LeetCode
Can you solve this real interview question? All Paths From Source to Target - Given a directed acyclic graph (DAG) of n nodes labeled from 0 to n - 1, find all possible paths from node 0 to node n - 1 and return them in any order.
The graph is given as follows:…
The graph is given as follows:…
Day-4: DFS
Clone Graph
Leetcode #133
Algorithm: DFS
Video for DFS: https://youtu.be/CvUMf8c2JFo
Please go through the video to understand DFS and then implement in the problem 🙂
Solution will be shared on the next day 🙂
#30DaysOfGraph #techdose #interviewpreparation #graphs #dsa
Clone Graph
Leetcode #133
Algorithm: DFS
Video for DFS: https://youtu.be/CvUMf8c2JFo
Please go through the video to understand DFS and then implement in the problem 🙂
Solution will be shared on the next day 🙂
#30DaysOfGraph #techdose #interviewpreparation #graphs #dsa
LeetCode
Clone Graph - LeetCode
Can you solve this real interview question? Clone Graph - Given a reference of a node in a connected [https://en.wikipedia.org/wiki/Connectivity_(graph_theory)#Connected_graph] undirected graph.
Return a deep copy [https://en.wikipedia.org/wiki/Object_c…
Return a deep copy [https://en.wikipedia.org/wiki/Object_c…
Day-4: Solution
Clone Graph
Leetcode #133
Algorithm: DFS
Video for DFS: https://youtu.be/CvUMf8c2JFo
Clone Graph (Solution): https://youtu.be/f2EfGComRKM
Please go through the video to understand DFS and then implement in the problem 🙂
#30DaysOfGraph #techdose #interviewpreparation #graphs #dsa
Clone Graph
Leetcode #133
Algorithm: DFS
Video for DFS: https://youtu.be/CvUMf8c2JFo
Clone Graph (Solution): https://youtu.be/f2EfGComRKM
Please go through the video to understand DFS and then implement in the problem 🙂
#30DaysOfGraph #techdose #interviewpreparation #graphs #dsa
LeetCode
Clone Graph - LeetCode
Can you solve this real interview question? Clone Graph - Given a reference of a node in a connected [https://en.wikipedia.org/wiki/Connectivity_(graph_theory)#Connected_graph] undirected graph.
Return a deep copy [https://en.wikipedia.org/wiki/Object_c…
Return a deep copy [https://en.wikipedia.org/wiki/Object_c…
Day-5:
Number of Operations to Make Network Connected
Leetcode #1319
Algorithm: Disjoint Set
Video for Disjoint Set (Union & Find): https://youtu.be/eTaWFhPXPz4
Video for Disjoint Set (Union by RANK & Find->Path Compression): https://youtu.be/kaBX2s3pYO4
Please go through the video to understand DFS and then implement in the problem 🙂
#30DaysOfGraph #techdose #interviewpreparation #graphs #dsa
Number of Operations to Make Network Connected
Leetcode #1319
Algorithm: Disjoint Set
Video for Disjoint Set (Union & Find): https://youtu.be/eTaWFhPXPz4
Video for Disjoint Set (Union by RANK & Find->Path Compression): https://youtu.be/kaBX2s3pYO4
Please go through the video to understand DFS and then implement in the problem 🙂
#30DaysOfGraph #techdose #interviewpreparation #graphs #dsa
LeetCode
Number of Operations to Make Network Connected - LeetCode
Can you solve this real interview question? Number of Operations to Make Network Connected - There are n computers numbered from 0 to n - 1 connected by ethernet cables connections forming a network where connections[i] = [ai, bi] represents a connection…
Day-5: Solution
Number of Operations to Make Network Connected
Leetcode #1319
Algorithm: Disjoint Set
Solution Link: https://youtu.be/3JIwIRir2sM
CODE Link: https://gist.github.com/SuryaPratapK/277764a98ebbfb3618091503611a2fa1
Video for Disjoint Set (Union & Find): https://youtu.be/eTaWFhPXPz4
Video for Disjoint Set (Union by RANK & Find->Path Compression): https://youtu.be/kaBX2s3pYO4
Please go through the video to understand Disjoint Set and then implement in the problem
#30DaysOfGraph #techdose #interviewpreparation #graphs #dsa
Number of Operations to Make Network Connected
Leetcode #1319
Algorithm: Disjoint Set
Solution Link: https://youtu.be/3JIwIRir2sM
CODE Link: https://gist.github.com/SuryaPratapK/277764a98ebbfb3618091503611a2fa1
Video for Disjoint Set (Union & Find): https://youtu.be/eTaWFhPXPz4
Video for Disjoint Set (Union by RANK & Find->Path Compression): https://youtu.be/kaBX2s3pYO4
Please go through the video to understand Disjoint Set and then implement in the problem
#30DaysOfGraph #techdose #interviewpreparation #graphs #dsa
LeetCode
Number of Operations to Make Network Connected - LeetCode
Can you solve this real interview question? Number of Operations to Make Network Connected - There are n computers numbered from 0 to n - 1 connected by ethernet cables connections forming a network where connections[i] = [ai, bi] represents a connection…
Day-5:
Number of Provinces
Leetcode #547
Algorithm: Disjoint Set
Video for Disjoint Set (Union & Find): https://youtu.be/eTaWFhPXPz4
Video for Disjoint Set (Union by RANK & Find->Path Compression): https://youtu.be/kaBX2s3pYO4
Please go through the video to understand Disjoint Set and then implement in the problem 🙂
#30DaysOfGraph #techdose #interviewpreparation #graphs #dsa
Number of Provinces
Leetcode #547
Algorithm: Disjoint Set
Video for Disjoint Set (Union & Find): https://youtu.be/eTaWFhPXPz4
Video for Disjoint Set (Union by RANK & Find->Path Compression): https://youtu.be/kaBX2s3pYO4
Please go through the video to understand Disjoint Set and then implement in the problem 🙂
#30DaysOfGraph #techdose #interviewpreparation #graphs #dsa
LeetCode
Number of Provinces - LeetCode
Can you solve this real interview question? Number of Provinces - There are n cities. Some of them are connected, while some are not. If city a is connected directly with city b, and city b is connected directly with city c, then city a is connected indirectly…
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
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
LeetCode
Number of Provinces - LeetCode
Can you solve this real interview question? Number of Provinces - There are n cities. Some of them are connected, while some are not. If city a is connected directly with city b, and city b is connected directly with city c, then city a is connected indirectly…
Day-7:
Evaluate Division
Leetcode #399
Algorithm: Disjoint Set
Video for Disjoint Set (Union & Find): https://youtu.be/eTaWFhPXPz4
Video for Disjoint Set (Union by RANK & Find->Path Compression): https://youtu.be/kaBX2s3pYO4
Please go through the video to understand Disjoint Set and then implement in the problem 🙂
#30DaysOfGraph #techdose #interviewpreparation #graphs #dsa
Evaluate Division
Leetcode #399
Algorithm: Disjoint Set
Video for Disjoint Set (Union & Find): https://youtu.be/eTaWFhPXPz4
Video for Disjoint Set (Union by RANK & Find->Path Compression): https://youtu.be/kaBX2s3pYO4
Please go through the video to understand Disjoint Set and then implement in the problem 🙂
#30DaysOfGraph #techdose #interviewpreparation #graphs #dsa
LeetCode
Evaluate Division - LeetCode
Can you solve this real interview question? Evaluate Division - You are given an array of variable pairs equations and an array of real numbers values, where equations[i] = [Ai, Bi] and values[i] represent the equation Ai / Bi = values[i]. Each Ai or Bi is…
Day-8: (Solution for Day-7 will be available in next 5 hours)
Detonate the Maximum Bombs
Leetcode #2101
Algorithm: BFS
BFS: https://youtu.be/YYq38LTz774
Please go through the video to understand BFS and then implement in the problem 🙂
#30DaysOfGraph #techdose #interviewpreparation #graphs #dsa
Detonate the Maximum Bombs
Leetcode #2101
Algorithm: BFS
BFS: https://youtu.be/YYq38LTz774
Please go through the video to understand BFS and then implement in the problem 🙂
#30DaysOfGraph #techdose #interviewpreparation #graphs #dsa
LeetCode
Detonate the Maximum Bombs - LeetCode
Can you solve this real interview question? Detonate the Maximum Bombs - You are given a list of bombs. The range of a bomb is defined as the area where its effect can be felt. This area is in the shape of a circle with the center as the location of the bomb.…
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
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
LeetCode
Evaluate Division - LeetCode
Can you solve this real interview question? Evaluate Division - You are given an array of variable pairs equations and an array of real numbers values, where equations[i] = [Ai, Bi] and values[i] represent the equation Ai / Bi = values[i]. Each Ai or Bi is…
Day-8: (Solution)
Detonate the Maximum Bombs
Leetcode #2101
Algorithm: BFS
BFS: https://youtu.be/YYq38LTz774
SOLUTION code: https://gist.github.com/SuryaPratapK/36c06f73ce2348fae189190aa52d7fdd
LOGIC:-
1 Make adjacency list using bombs in range of a bomb as adjacent bombs
2 Apply BFS from all bombs and track max depth of BFS call.
Please go through the video to understand BFS and then implement in the problem 🙂
#30DaysOfGraph #techdose #interviewpreparation #graphs #dsa
Detonate the Maximum Bombs
Leetcode #2101
Algorithm: BFS
BFS: https://youtu.be/YYq38LTz774
SOLUTION code: https://gist.github.com/SuryaPratapK/36c06f73ce2348fae189190aa52d7fdd
LOGIC:-
1 Make adjacency list using bombs in range of a bomb as adjacent bombs
2 Apply BFS from all bombs and track max depth of BFS call.
Please go through the video to understand BFS and then implement in the problem 🙂
#30DaysOfGraph #techdose #interviewpreparation #graphs #dsa
LeetCode
Detonate the Maximum Bombs - LeetCode
Can you solve this real interview question? Detonate the Maximum Bombs - You are given a list of bombs. The range of a bomb is defined as the area where its effect can be felt. This area is in the shape of a circle with the center as the location of the bomb.…
Day-9:
Is Graph Bipartite?
Leetcode #785
Algorithm: Bipartite Graph
Bipartite Graph: https://youtu.be/0ACfAqs8mm0
Please go through the video to understand BFS and then implement in the problem 🙂
#30DaysOfGraph #techdose #interviewpreparation #graphs #dsa
Is Graph Bipartite?
Leetcode #785
Algorithm: Bipartite Graph
Bipartite Graph: https://youtu.be/0ACfAqs8mm0
Please go through the video to understand BFS and then implement in the problem 🙂
#30DaysOfGraph #techdose #interviewpreparation #graphs #dsa
LeetCode
Is Graph Bipartite? - LeetCode
Can you solve this real interview question? Is Graph Bipartite? - There is an undirected graph with n nodes, where each node is numbered between 0 and n - 1. You are given a 2D array graph, where graph[u] is an array of nodes that node u is adjacent to. More…
Day-9: (Solution)
Is Graph Bipartite?
Leetcode #785
Algorithm: Bipartite Graph
Bipartite Graph: https://youtu.be/0ACfAqs8mm0
SOLUTION code: https://gist.github.com/SuryaPratapK/e7a6d806c218f81453f9fd61d41cec30
Please go through the video to understand Bipartite Graph and then implement in the problem 🙂
#30DaysOfGraph #techdose #interviewpreparation #graphs #dsa
Is Graph Bipartite?
Leetcode #785
Algorithm: Bipartite Graph
Bipartite Graph: https://youtu.be/0ACfAqs8mm0
SOLUTION code: https://gist.github.com/SuryaPratapK/e7a6d806c218f81453f9fd61d41cec30
Please go through the video to understand Bipartite Graph and then implement in the problem 🙂
#30DaysOfGraph #techdose #interviewpreparation #graphs #dsa
LeetCode
Is Graph Bipartite? - LeetCode
Can you solve this real interview question? Is Graph Bipartite? - There is an undirected graph with n nodes, where each node is numbered between 0 and n - 1. You are given a 2D array graph, where graph[u] is an array of nodes that node u is adjacent to. More…
Day-10:
Possible Bipartition
Leetcode #886
Algorithm: Bipartite Graph
Bipartite Graph: https://youtu.be/0ACfAqs8mm0
Please go through the video only after trying the problem yourself to understand Bipartite Graph and then implement in the problem 🙂
#30DaysOfGraph #techdose #interviewpreparation #graphs #dsa
Possible Bipartition
Leetcode #886
Algorithm: Bipartite Graph
Bipartite Graph: https://youtu.be/0ACfAqs8mm0
Please go through the video only after trying the problem yourself to understand Bipartite Graph and then implement in the problem 🙂
#30DaysOfGraph #techdose #interviewpreparation #graphs #dsa
LeetCode
Possible Bipartition - LeetCode
Can you solve this real interview question? Possible Bipartition - We want to split a group of n people (labeled from 1 to n) into two groups of any size. Each person may dislike some other people, and they should not go into the same group.
Given the integer…
Given the integer…
Day-10: (Solution)
Possible Bipartition
Leetcode #886
Algorithm: Bipartite Graph
Bipartite Graph: https://youtu.be/0ACfAqs8mm0
SOLUTION code: https://gist.github.com/SuryaPratapK/4c9ad30caa5f3c8b6c1249b0ed664e72
Please go through the video only after trying the problem yourself to understand Bipartite Graph and then implement in the problem 🙂
#30DaysOfGraph #techdose #interviewpreparation #graphs #dsa
Possible Bipartition
Leetcode #886
Algorithm: Bipartite Graph
Bipartite Graph: https://youtu.be/0ACfAqs8mm0
SOLUTION code: https://gist.github.com/SuryaPratapK/4c9ad30caa5f3c8b6c1249b0ed664e72
Please go through the video only after trying the problem yourself to understand Bipartite Graph and then implement in the problem 🙂
#30DaysOfGraph #techdose #interviewpreparation #graphs #dsa
LeetCode
Possible Bipartition - LeetCode
Can you solve this real interview question? Possible Bipartition - We want to split a group of n people (labeled from 1 to n) into two groups of any size. Each person may dislike some other people, and they should not go into the same group.
Given the integer…
Given the integer…
Day-11:
Graph Valid Tree
Leetcode #886
Read : When can we call a Graph as TREE ?
Please try the problem yourself and read the properties for a GRAPH to be called a tree 🙂
#30DaysOfGraph #techdose #interviewpreparation #graphs #dsa
Graph Valid Tree
Leetcode #886
Read : When can we call a Graph as TREE ?
Please try the problem yourself and read the properties for a GRAPH to be called a tree 🙂
#30DaysOfGraph #techdose #interviewpreparation #graphs #dsa
LeetCode
Graph Valid Tree - LeetCode
Can you solve this real interview question? Graph Valid Tree - Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.
Day-11: (Solution)
Graph Valid Tree
Leetcode #886
Read : When can we call a Graph as TREE ?
SOLUTION code: https://gist.github.com/SuryaPratapK/e9d3dc3063b8c64805ff8adbfcf4cef5
Steps:-
A graph is TREE when:-
1 It is connected (has only 1 component)
2 It has no cycle
Please try the problem yourself and read the properties for a GRAPH to be called a tree 🙂
#30DaysOfGraph #techdose #interviewpreparation #graphs #dsa
Graph Valid Tree
Leetcode #886
Read : When can we call a Graph as TREE ?
SOLUTION code: https://gist.github.com/SuryaPratapK/e9d3dc3063b8c64805ff8adbfcf4cef5
Steps:-
A graph is TREE when:-
1 It is connected (has only 1 component)
2 It has no cycle
Please try the problem yourself and read the properties for a GRAPH to be called a tree 🙂
#30DaysOfGraph #techdose #interviewpreparation #graphs #dsa
LeetCode
Graph Valid Tree - LeetCode
Can you solve this real interview question? Graph Valid Tree - Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.