This is a verified interview question from Uber. Candidates reporting seeing this problem in recent Online Assessments (OAs) and onsite rounds. Mastering "Ride Request Queue Insertion" covers key patterns like Graphs.
"You are working on Uber's driver network analysis system, which models drivers as nodes in a graph. A connection (edge) exists between two drivers if they frequently operate in the same area or share rides in pooled trips. Uber wants to analyze these connected groups of drivers (connected components) to optimize demand prediction and driver incentives. Definitions A connected group of drivers is a connected component. The order of a component = number of drivers in it. The support value of a component = ceil(sqrt(component_size)) Goal Return the total support value across all connected components. Function Signature int totalSupport( int drivers_nodes, vector<int> drivers_from, vector<int> drivers_to ); Example Explanation If components are: (1,2,3,4,5) → size = 5 → ceil(√5) = 3 (7,8) → size = 2 → ceil(√2) = 2 Three isolated nodes → each size = 1 → ceil(√1) = 1 Total = 3 + 2 + 1 + 1 + 1 = 8"
Join thousands of developers practicing for Uber.