Skip to content

PRO TIP Block youtube.com at the DNS level β€” Pi-hole, NextDNS or your hosts file β€” but allow youtube-nocookie.com and i.ytimg.com. These tutorials keep playing; the rabbit hole does not.

Learning without distractions

DSA in Python – Shortest Path in Undirected Graph with Unit Distance | BFS | GFG | Part 142 [Hindi]

2.2K views on YouTube

πŸš€ Welcome to Part 142 of Code & Debug’s DSA in Python Course!

In this session, we solve the problem Shortest Path in an Undirected Graph with Unit Distance from GFG using the Breadth-First Search (BFS) algorithm.

This is a classic single-source shortest path problem where edge weights are 1, making BFS the most efficient approach.

πŸ” What you’ll learn in this video:
βœ… Why BFS works best for graphs with unit weights
βœ… How to initialize distance array properly
βœ… BFS traversal for minimum path discovery
βœ… Handling disconnected nodes (distance = -1)
βœ… Complete time & space complexity breakdown

πŸ“„ GFG Problem Link:
https://www.geeksforgeeks.org/problems/shortest-path-in-undirected-graph-having-unit-distance/1

πŸ‘‰ Refer to the article for better understanding:
πŸ”— https://codeanddebug.in/blog/shortest-path-in-an-undirected-graph/

πŸ“š Python DSA Course Playlist with Sheet:
https://docs.google.com/spreadsheets/d/1AWE15Fy3wD2iqu2vjK_R7cCiuvSsjYQclcdZmHpF66o/edit?usp=sharing

🧠 Zero to Hero DSA Course:
https://codeanddebug.in/course/zero-to-hero-python-dsa

🧩 Leetcode-Based DSA Masterclass (Free):
https://codeanddebug.in/course/master-dsa-with-leetcode

πŸ‘ Like, πŸ” Share, πŸ’¬ Comment your doubts, and πŸ”” Subscribe for more such DSA breakdowns!

#ShortestPath #BFS #GraphAlgorithms #UndirectedGraph #GFG #PythonDSA #CodeAndDebug #Part142 #SingleSourceShortestPath #UnitDistanceGraph