Home /
Expert Answers /
Computer Science /
please-do-it-in-python-frank-and-the-mathematics-teacher-one-day-frank-39-s-mathematics-teacher-deci-pa431
(Solved): please do it in python Frank and the Mathematics Teacher One day, Frank's Mathematics teacher decide ...
please do it in python
Frank and the Mathematics Teacher One day, Frank's Mathematics teacher decides to test everyone on the permutations topic, so he gives them a problem to work out. He gives them a permutation of first \( \mathrm{N} \) natural numbers and also a rule that every number should occur only once in the permutation. The students have to find the minimum number of steps to convert the permutation to a new permutation according to the rule where they can only replace a number with another number. Only Frank was able to solve the problem, you also have to solve the problem like Frank. Input Specification: input1: The number \( \mathrm{N} \) input2: The array representing the original permutation
Explanation 1: Since all numbers till \( N \) are present once, no steps need to be performed. Example 2: input1: 4 input2: \( \{4,3,2,2\} \)
Explanation 1: Since all numbers till \( N \) are present once, no steps need to be performed. Example 2: input1: 4 input2: \( \{4,3,2,2\} \) Output: 1 Explanation 2: The third number can be replaced by 1 to make this the correct permutation.
\# Read only region start class UserMainCode(object): @classmethod def permutation(cls, input1, input2): input1 : int input2 : int[] Expected return type : int \# Read only region end \# Write code here pass