In this challenge, there is a connected undirected graph where each of the nodes is a color. Given a color, find the shortest path connecting any two nodes of that color. Each edge has a weight of 1. If there is not a pair or if the color is not found, print -1.
Link of the above problem : https://www.hackerrank.com/challenges...
Another problem where BFS was used: • LEETCODE: AVERAGE OF LEVELS IN BINARY TREE
#bfs
#hackerrank