This theory is part of Premium
The full write-up (worked counting examples, the trap list and the interview playbook) unlocks with a Premium plan, along with every Pro visualizer.
See pricingAn MST in disguise with a catch: pick the cheapest links so every city is connected, or report -1.
What this asks
Connect every city at the lowest total cost, or report it impossible.
An MST over the affordable links; if union-find ends with more than one group, the answer is -1.
The full write-up (worked counting examples, the trap list and the interview playbook) unlocks with a Premium plan, along with every Pro visualizer.
See pricing