Get Sizes of Friends Groups π₯
As new students begin to arrive at college, each receives a unique ID number, 1 to n. Initially, the students do not know one another, and each has a different circle of friends. As the semester progresses, other groups of friends begin to form randomly.
There will be three arrays, each aligned by an index. The first array will contain a queryType which will be either Friend or Total. The next two arrays, students1 and students2, will each contain a student ID. If the query type is Friend, the two students become friends. If the query type is Total, report the sum of the sizes of each group of friends for the two students.
Complete the function getSizesOfFriendsGroups in the editor.
getSizesOfFriendsGroups has the following parameters:
- 1.
String[] queryType: an array of strings representing the type of query - 2.
int[] student1: an array of integers representing the first student IDs - 3.
int[] student2: an array of integers representing the second student IDs - 4.
n: the number of students
Returns
queryType = ["Friend", "Friend", "Total"] student1 = [1, 2, 1] student2 = [2, 3, 4] n = 4 return = 4

Unknown for now π±- Maximize Total Profit by Assigning Chefs to DishesPHONE SCREEN Β· Seen May 2026
- Closest DashMartPHONE SCREEN Β· Seen Jun 2025
- Return Priority of Order IDsPHONE SCREEN Β· Seen Jun 2025
- Adjust Prices π±Seen Oct 2024
- Discount EventsSeen Oct 2024
- Team FormationSeen Oct 2024
- Calculate Difference Value π§Seen Mar 2024
public int getSizesOfFriendsGroups(String[] queryType, int[] student1, int[] student2, int n) {
// write your code here
}