Search This Blog

Showing posts with label BFS. Show all posts
Showing posts with label BFS. Show all posts

Monday, July 6, 2020

The Flight Plan - 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 we have use dictionary named "dd" in which we store its parent node if we print that dictionary we get the path for for each node from source given node.
For the Problem goto below link and search for problem: The Flight Plan

Code :

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 :

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 :

Alien Dictionary

code:   from collections import defaultdict class Solution:     def __init__(self):         self.graph=defaultdict(list)                  ...