• Tutorials
  • DSA
  • Data Science
  • Web Tech
  • Courses
August 22, 2024 |100 Views

PROBLEM OF THE DAY : 21/08/2024 | Shortest Path in Undirected Graph

Description
Discussion

Welcome to the daily solving of our PROBLEM OF THE DAY with Nitin Kaplas We will discuss the entire problem step-by-step and work towards developing an optimized solution. This will not only help you brush up on your concepts of Graph but also build up problem-solving skills.

You are given an Undirected Graph having unit weight of the edges, find the shortest path from src to all the vertex and if it is unreachable to reach any vertex, then return -1 for that vertex.

Examples :

Input: n = 9, m = 10 edges=[[0,1],[0,3],[3,4],[4,5],[5,6],[1,2],[2,6],[6,7],[7,8],[6,8]] src=0 Output: 0 1 2 1 2 3 3 4 4

Give the problem a try before going through the video. All the best!!!
Problem Link: https://practice.geeksforgeeks.org/problems/shortest-path-in-undirected-graph-having-unit-distance/1