Back to Browse

Shortest Routes II (CSES) | Floyd-Warshall Algorithm Explained

690 views
Jul 1, 2025
28:39

🌐 What if you had to find the shortest distance between every pair of cities? That’s what the CSES Shortest Routes II problem is all about — and to solve it, we use the powerful Floyd-Warshall algorithm, a dynamic programming approach to all-pairs shortest paths. This video walks you through how and why it works, and how it compares to other algorithms like Dijkstra. 📄 𝐍𝐨𝐭𝐞𝐬: https://github.com/yash7xm/cp_notes/tree/master/cses/graphs We’ll break down the triple loop structure, explain why it works even with dense graphs, and show how the core logic relies on updating distances through intermediate nodes. Whether you're solving graph theory problems or preparing for interviews, Floyd-Warshall is a must-have in your CP toolbox. By the end of the video, you’ll be able to solve all-pairs shortest path queries efficiently, and understand the depth behind the elegance of this algorithm. Part of the complete CSES Graph Problem Set playlist. If you’re serious about mastering graph algorithms, this is your next step. #FloydWarshall #AllPairsShortestPath #CSES #GraphDP #CompetitiveProgramming

Download

1 formats

Video Formats

360pmp434.1 MB

Right-click 'Download' and select 'Save Link As' if the file opens in a new tab.

Shortest Routes II (CSES) | Floyd-Warshall Algorithm Explained | NatokHD