This is a verified interview question from Uber. Candidates reporting seeing this problem in recent Online Assessments (OAs) and onsite rounds. Mastering "Uber – Optimize Delivery Network - Uber Online Assessment IIT BHU Data Science Role" covers key patterns like Arrays.
"Uber operates a delivery network consisting of N hubs connected by N − 1 bidirectional roads, forming a tree. Each road has a throughput value representing the number of deliveries it can efficiently support. To reduce infrastructure costs, Uber plans to permanently close some roads. After the closures: Each hub can remain directly connected to at most K other hubs. The remaining roads do not have to keep the network fully connected. The goal is to maximize the sum of throughput values of all roads that remain open. Given the road network, determine the maximum total throughput that can be preserved. Function Description Complete the function maximizeDeliveryThroughput. ``` long long maximizeDeliveryThroughput( int n, vector<vector<int>> roads, int k ); ``` Parameters n — Number of hubs. roads[i] = [u, v, w] — A bidirectional road connecting hubs u and v with throughput w. k — Maximum number of roads that may remain connected to any hub. Returns long long — The maximum total throughput of the remaining roads."
Join thousands of developers practicing for Uber.