Company: uber_3sep
Difficulty: medium
Connected Sum Problem Description You're building an analytics tool for a ride-hailing platform that models its drivers as nodes in a graph. An edge connects two drivers whenever they regularly cover the same area or have shared a pooled ride together. The platform wants to study these connected clusters of drivers (its connected components) to fine-tune demand forecasting and driver incentive payouts. Each connected cluster of drivers forms one connected component. The order of a component is however many drivers belong to it. Every component is assigned a "support value" equal to the ceiling of the square root of its size. The goal is to add up the support values across every cluster. For example, take drivers_nodes = 10 , drivers_from = [1, 2, 3, 7] , and drivers_to = [2, 3, 4, 8] . These define the edges (1,2), (2,3), (3,4), (7,8). The connected components here are: {1, 2, 3, 4} (size 4). Support value: ceil(sqrt(4)) = 2 . {7, 8} (size 2). Support value: ceil(sqrt(2)) = 2 . {5} (si