InterviewDB
Question
Thrilling Teleporters: Find Minimum Jumps to Traverse a Graph with Teleport Edges
Question Details
Problem You have a graph with n nodes. Most edges cost 1 jump. Some edges are "teleporters" that cost 0 jumps (you are instantly transported). Find the minimum number of jumps to travel from node src to node dst. Example: Approach Use 0-1 BFS (deque): enqueue with appendleft for 0-cost edges and append for 1-cost edges. This gives correct shortest paths without a full Dijkstra. Follow-ups Why does 0-1 BFS produce correct shortest paths? Prove the invariant. How does 0-1 BFS compare to Dijkstra i…
Full Details
🔒
Unlock all Karat questions
Full insider details, leaked discussions, and candidate experiences.
or every company, $100/year →About This Question
This is a reported interview question from a karat interview.