Company: Microsoft IIT BHU
Difficulty: medium
Count Connected Nodes in DSU Problem Description A network has n nodes labelled 1 through n , joined by m undirected edges. Two nodes are in the same component when you can walk from one to the other along edges, in any number of steps. You are then given q queries. For each query node, report how many nodes lie in its component, counting the query node itself . Notes: An edge may appear more than once, and an edge may join a node to itself. Neither changes which nodes are connected. A node with no edges forms a component of size 1. The same node may be queried more than once. Function Description Complete the process_queries() function provided in the editor. It takes three parameters: n: the number of nodes edges: the m edges, each a pair [u, v] queries: the q nodes to report on It returns one component size per query, in the order the queries are given. Input Format The first line contains two integers n and m . Each of the next m lines contains two integers u and v , an undirected