Cheapest International Wire Route With Limited Intermediary Banks
Last updated: November 29, 2026
Quick Overview
Wires can move between banks over directed correspondent links, each charging a fee. Return the lowest total fee to send a wire from a source bank to a destination bank passing through at most k intermediary banks, or -1 if no such route exists.
Capital One
November 29, 20260
0
0 solved
Wires can move between banks over directed correspondent links, each charging a fee. Return the lowest total fee to send a wire from a source bank to a destination bank passing through at most k intermediary banks, or -1 if no such route exists.
International wires often route through correspondent banks, each taking a fee, and long chains add delay and compliance risk, so routes are capped. This onsite question checks whether you see that plain Dijkstra ignores the hop limit and whether you can apply bounded Bellman-Ford correctly.
What the Interviewer Expects
- Translate k intermediaries into k + 1 edges
- Run Bellman-Ford for exactly k + 1 rounds
- Relax from a copy of the previous round to avoid chaining in one round
- Stop early when a round makes no improvement
- Explain why unmodified Dijkstra gives wrong answers
Key Topics to Cover
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
- How would you return the route itself?
- How would you adapt Dijkstra with state (bank, hops used)?
- What if fees are a percentage of the amount instead of a flat value?
- How would you exclude banks on a sanctions list at query time?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
- Banks 0..n-1, directed links
(from, to, fee)with non-negative fees in cents. - At most k intermediary banks means at most k + 1 links.
- Output: the minimum total fee, or -1....
High-Level Design
Round r of Bellman-Ford computes the cheapest cost using at most r edges, provided each round relaxes only from the previous round's costs. Relaxing in place would let one round chain several edges an...