Graphs pattern
Find the City With Fewest Reachable
Given an undirected weighted graph of cities and a distance threshold, find the city that can reach the fewest other cities within the threshold distance. If several cities tie, return the one with the largest index. Watch it run step by step, then write your own pseudocode and get it checked by AI.
- LeetCode 1334
- Medium
- 1 approach
Sign in with Google or GitHub and you land straight on this page. DSA comes with the all labs plan and every ChaiCode batch.
GraphsLeetCode 1334
Medium
The approach
- 01 Floyd-Warshall + count O(V³)O(V²) space
What you will learn
- How to read Find the City With Fewest Reachable and spot the graphs pattern in it
- Floyd-Warshall + count: O(V³) time, O(V²) space
- The pseudocode for each approach, its line lit as the animation runs
- Practice: write your own pseudocode and get it checked
More Graphs
See Find the City With Fewest Reachable run, step by step
Sign in and this page opens on the animation, with all 9 Graphs problems beside it.
DSA comes with the all labs plan and every ChaiCode batch.