Answer: LEONARDO DRS Hiring | Online Assessment Interview Question | On-Campus(2023)

Answer · Posted Jun 2026

Approach If the number of cables is less than n - 1, it is impossible to connect all computers. Initialize each computer as its own parent using Union-Find (Disjoint Set Union). Traverse every connection and merge the connected computers. Count the number of connected components. The answer is components - 1. Strategy Use the Union-Find (Disjoint Set Union) data structure. Every successful union reduces the number of connected components. Finally, connect all remaining components using the minimum number of operations. ...

The full answer & interview discussion are available to premium members.

Log in Create a free account