Monday, July 6, 2020
Social Networking Graph - Hackerearth Problem Solution Using Python
Here , To solve this problem we have use the BFS algorithm using python in which we just add a "dist" list in which we store distance of every node from its parent node. And then we see count nodes which are at a given distance from given source node.
For the Problem goto below link and search for problem:
Social Networking Graph
Code :
Code :
Sunday, July 5, 2020
Monk and the Islands - Hackerearth Problem Solution Using Python
Here , To solve this problem we have use the BFS algorithm using python in which we just add a "dist" list in which we store distance of every node from its parent node.
For the Problem goto below link and search for problem:
Monk and Islands
Code :
Code :
Shortest Path Using Breadth First Search (BFS)
Shortest Path Using Breadth First Search (BFS)
Here , To find the shortest path using BFS first we have to know that the graph should always be unweighted graph .
If you know about the BFS algorithm then to find shortest path we have to add only one thing that is a dictionary named "dist" which records the distance of every node from given node As shown in below code.
Code :
Code :
Subscribe to:
Posts (Atom)
Alien Dictionary
code: from collections import defaultdict class Solution: def __init__(self): self.graph=defaultdict(list) ...
-
Here , To solve this problem we have use the BFS algorithm using python in which we just add a "dist" list in which we store ...
-
Byte Stuffing Mechanism If the pattern of the flag byte is present in the message byte sequence, there should be a strategy so that the ...
-
code: def pathUtil(maze,visited,sol,x,y,N,possible): #print(sol) if x<0 or y<0 or x>N-1 or y>N-1 or maze[x][y]==0 or ...