VMWARE MTS OA (2023) | Graph Connectivity Optimization Using Greedy Algorithms and Disjoint Set Union

Question · Posted Jun 2026

Q1. Minimum Spanning Tree (Kruskal's Algorithm) Problem Statement You are given: An integer n representing the number of nodes. A list of weighted undirected edges: edges[i] = [u, v, w] where: u and v are connected nodes. w is the weight of the edge. Your task is to connect all nodes with the minimum possible total cost. Return the total weight of the Minimum Spanning Tree (MST). If it is impossible to connect all nodes, return: -1 Example 1 Input ...

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

Log in Create a free account