Company: uber_24feb
Difficulty: medium
Uber City Network Construction Uber is expanding its core infrastructure to support faster ride dispatching, pricing updates, and real-time tracking across a city. The city can be visualized as a large coordinate grid where n Uber operational hubs (such as dispatch centers or regional data hubs) are placed at various coordinates. The i th hub is located at ( x[i] , y[i] ). To enable communication between hubs, Uber can directly connect any two hubs i and j . The cost of establishing a direct connection between hub i and hub j is defined as: min(| x[i] - x[j] |, | y[i] - y[j] |), where |a| denotes the absolute value of integer a . Given arrays x and y of n integers each, determine the minimum total cost required to build the Uber network such that every hub can communicate with every other hub, either directly or indirectly. Example Suppose n = 3, x = [2, 4, 8], and y = [6, 10, 9]. The Uber hubs are located at coordinates (2, 6), (4, 10), and (8, 9). It is optimal to connect the first h