Question: You are given a number n which denotes the number of students in a class. You are given Q queries and two arrays student 1

You are given a number n which denotes the number of students in a class. You are given Q
queries and two arrays student1 and student2 of size Q each. A query can be of 2 types -
Friend,Total. If the query is Friend, then make student1[q] and student2[q] each others
friends. q refers to the serial number of the query, i.e., the index in the queries array. If the
query is of type Total, then return the total number of the students in the group of
student1[q] and student2[q]. They both might be in the same group, so you do not need to
count twice in that case

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!