Uber 2024 Papers
Previous year papers with coding questions
Practice Uber placement paper coding questions with detailed solutions. Access Uber OA coding problems in Java, Python, JavaScript.
This page contains Uber coding questions from Uber OA placement papers with detailed solutions.
Uber OA Coding Section:
Solution (Java):
public List<Location> findOptimalRoute(Location start, Location end, Map<Location, List<Edge>> graph) { // Use Dijkstra's algorithm with traffic weights PriorityQueue<PathNode> pq = new PriorityQueue<>((a, b) -> Double.compare(a.totalTime, b.totalTime)); Map<Location, Double> distances = new HashMap<>(); Map<Location, Location> previous = new HashMap<>();
pq.offer(new PathNode(start, 0.0)); distances.put(start, 0.0);
while (!pq.isEmpty()) { PathNode current = pq.poll(); if (current.location.equals(end)) break;
for (Edge edge : graph.getOrDefault(current.location, new ArrayList<>())) { double newTime = current.totalTime + edge.timeWithTraffic; if (newTime < distances.getOrDefault(edge.to, Double.MAX_VALUE)) { distances.put(edge.to, newTime); previous.put(edge.to, current.location); pq.offer(new PathNode(edge.to, newTime)); } } }
return reconstructPath(previous, start, end);}Time Complexity: O((V + E) log V)
Uber 2024 Papers
Previous year papers with coding questions
Uber Main Page
Complete Uber placement guide
Practice Uber coding questions regularly!