Message on Whatsapp 8879355057 for DSA(OA + Interview) + Fullstack Dev Training + 1-1 Personalized Mentoring to get 10+LPA Job
0 like 0 dislike
1,741 views
in Online Assessments by Expert (34,270 points) | 1,741 views

1 Answer

0 like 0 dislike

Section 3 - Disconnected Nodes (Coding, 30 mins)

 

Problem statement: there is an undirected graph with n nodes and some edges, there is also an array of m integers disconnected_nodes, which represnt the array of nodes that are not reachable from one another via any path. No two nodes in the array are connected directly or indirectly.
Find the maximum number of edges that can be added to the graph such that the set of disconnected_nodes remains disconnected.

 

Example:
Input - n = 6, edges = [[1,2], [1,3], [2,3], [4,5]], disconnected_nodes = [2, 4]
output - 3
Explanation - following edges can be added [6,1] , [6,2], [6,3]

by Expert (34,270 points)
0 0
The is a 24 in coding edges