Find Connected Components in a Cloud Network

Last updated: December 9, 2025

Quick Overview

Given a set of cloud resources and their network connectivity (VPC peering, transit gateways, VPN connections), find all network-isolated groups of resources. Identify resources that are unexpectedly connected or isolated.

Wiz
Coding & Algorithms
Software Engineer
Wiz
December 9, 2025
Software Engineer
Technical Phone Screen
Coding & Algorithms
Medium

15

4

3,995 solved


Given a set of cloud resources and their network connectivity (VPC peering, transit gateways, VPN connections), find all network-isolated groups of resources. Identify resources that are unexpectedly connected or isolated.

Understanding network segmentation is critical for cloud security. Resources that should be isolated (production vs development, different customer environments) must not be transitively connected through VPC peering chains or shared transit gateways. This problem tests your graph fundamentals and ability to apply them to security concepts.

What the Interviewer Expects
  • Implement connected components using BFS/DFS or Union-Find
  • Handle both directed (security groups) and undirected (VPC peering) edges
  • Identify unexpectedly large components that suggest missing segmentation
  • Analyze complexity and discuss Union-Find optimization
Key Topics to Cover
Connected components algorithm
Union-Find data structure
Network segmentation analysis
BFS/DFS graph traversal
Cloud networking concepts
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
  • How would you handle the case where some connections are unidirectional?
  • What if you need to find components dynamically as edges are added/removed?
  • How would you recommend segmentation improvements based on the components?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice DSA Problems
Sample Answer
Problem Analysis

This problem can be modeled as a graph where each cloud resource represents a node and the connections (like VPC peering and VPN connections) represent edges. The goal is to find all connected compone...

Approach
  1. Graph Representation: Represent the cloud resources and their connections using an adjacency list. For each resource, list its direct connections.
  2. Union-Find Initialization: Initialize a...

Submit Your Answer
Markdown supported

Related Questions