Get best answers to any doubt/query/question related to programming , jobs, gate, internships and tech-companies. Feel free to ask a question and you will receive the best advice/suggestion related to anything you ask about software-engineering , development and programming problems .

0 like 0 dislike
3,217 views
in Online Assessments by Expert (32,020 points)

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 (32,020 points)
0 0
The is a 24 in coding edges
...