Company: Meesho
Difficulty: medium
Visible Profiles A popular social media platform provides a feature to connect people online. Connections are represented as an undirected graph where a user can see the profiles of those they are connected to. There are connection_nodes users, numbered 1 to connection_nodes , and connection_edges connections, where the i -th connection joins the users connection_from[i] and connection_to[i] . Visibility spreads through the network. If user a is connected to user b and user b is connected to user c , then a can see c 's profile as well, even though a and c are not directly connected. Every user can always see their own profile. The queries array contains user numbers. For each queries[i] , find the number of users whose profiles are visible to queries[i] , and report an array of integers where the i -th value is the answer to the i -th query. Input Format The first line contains two space-separated integers, connection_nodes and connection_edges . Each of the next connection_edges line