There are in students in Geekland numbered from 1 to n and m schools numbered from 1 to…
- User
There are in students in Geekland numbered from 1 to n and m schools numbered from 1 to m We are given an array arr whose length is n which represents that ith students belongs to arr[i] school intially. We are given an integer array strength of Inngth n where strength[i] represents the strength of ith student. Now we are given an 2D integer array transfers whose longth is whore transfers[i]-[child, school] means that aftor in transfor child, belongs to school. After cach transfer we calculate the oddness of each school and return the maximum oddness among all schools.Oddness of a school is defined as the minimum strength of all the students studying in that school. So we have to return an array of length transfers where ith element corresponds to the maximum oddness among all schools after the th transfer took place Transfers should be performed in same order as given in the 20 integer array transfers[][] Note: if school has no student its oddness is considered as 0. Example 1: Input n=3 m-3 9-2 arr-[1.2.3] strength-[1.3.4] transfer-(1,3),(3.1]] Output: [3.4] Explanation: After Ist transfer student 2 belongs to school 2 and student 1,3 belongs to school 3. Now oddness of school. 1 is O as no student oddness of school 2 is 3 oddness of school 3 is 1 min(1,4) so maximum values among all oddness 15 3 so 3 is the result after 1st tranfer After 2nd tranfer happens student 1 belongs to school 3 and student 2 belongs school 2 and student 3 belongs school 1 Now addness of schnol 1.2.3 are 4.3.1 respectively so maximum values among all odidness is 4. So 4 is the result after 2nd transfer
class Solution: def maxStudent(self,n,m,q,arr,strength,transfers) -> int: # code here
- Assistant