HACKERRANK : FIND THE NEAREST CLONE [EXPLANATION + CODEWALK ]

Опубликовано: 04 Май 2026
на канале: Anand Pandey
3,818
56

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