Solve island connectivity and string multiplication
Company: Meta
Role: Software Engineer
Category: Coding & Algorithms
Difficulty: medium
Interview Round: Technical Screen
Overview: This question evaluates graph connectivity reasoning (computing minimum edges to unify components) and string-based big-integer arithmetic (multiplying numbers represented as strings), testing competency in graph theory, component analysis, and numeric string manipulation.
Constraints
- 1 <= n <= 200000
- 0 <= len(connections) <= 200000
- connections[i] = [u, v], where 0 <= u, v < n and u != v
- Islands are distinct and labeled 0 to n-1
- Multiple or duplicate connections may be present and should be treated as a single connection for connectivity
Hints
- The minimum number of additional paths required equals the number of connected components minus one.
- Use DFS/BFS or Union-Find (Disjoint Set Union) to count connected components efficiently.
- Be careful to handle duplicate connections without affecting the component count.