SALESFORCE | Disjoint Set Union and Graph Connectivity Analysis | SWE OA 2022 to 2023 Hiring
Salesforce · Question · Posted Jun 2026
Q1. Number of Connected Components in an Undirected Graph Problem Statement You are given: An integer n representing the number of nodes. A list of undirected edges where: edges[i] = [u, v] indicates a connection between node u and node v. Return the number of connected components present in the graph. A connected component is a group of nodes where every node is reachable from every other node in that group. Example 1 Input n = 5 edges = [[0,1],[1,2],[3,4]] ...
The full answer & interview discussion are available to premium members.
Log in Create a free account