Minimum Delivery Cost Between Cities
Last updated: July 3, 2026
Quick Overview
The question asks the candidate to determine the minimum delivery cost between cities given a set of routes and their respective costs.
Uber
July 3, 202617
0
133 solved
The question asks the candidate to determine the minimum delivery cost between cities given a set of routes and their respective costs.
This question is typically asked during the online assessment round for software engineering candidates at Uber to evaluate their problem-solving and algorithmic skills. The interviewer is looking for the candidate's ability to apply graph theory concepts, particularly in finding the shortest path in a weighted graph, which is a common scenario in logistics and transportation applications.
What the Interviewer Expects
- Demonstrates understanding of graph representation and traversal algorithms.
- Clearly explains the chosen algorithm for finding the minimum cost.
- Provides a correct and efficient implementation of the solution.
- Discusses time and space complexity of the solution.
- Considers edge cases and potential pitfalls in the implementation.
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
- What would you do if there were negative weights on the edges?
- How would you optimize your solution for larger datasets?
- Can you explain how your solution could be adapted for real-time delivery tracking?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Approach
To solve the problem of finding the minimum delivery cost between cities, I will represent the cities and routes as a graph. Each city will be a node, and each route with its cost will be an edge with...
Algorithm
- Initialize a priority queue to store the cities to explore, starting with the source city.
- Create a dictionary to track the minimum cost to reach each city, initializing the source city cost to ...