Company: BNY_18nov
Difficulty: medium
Permutation Operations Problem Description A permutation of n numbers is a sequence where each number from 1 to n appears exactly once. For a given permutation p and any arbitrary array arr, a permutation operation is defined as: For each index i (1 <= i <= n), temp_arr[i] = arr[p[i]] arr = temp_arr Given a permutation p of n distinct elements, start with any arbitrary array arr of n distinct elements and find the minimum number of permutation operations (at least 1) needed in order to reach the original array. Since the answer can be quite large, return the answer modulo (10^7 + 7). Function Description Complete the function countOperations in the editor below. countOperations has the following parameter: int p[n]: a permutation of the integers from 1 to n. Returns int: the number of operations required modulo (10^7 + 7) Examples Example 1: Input: n = 3 p = [2, 3, 1] Output: 3 Explanation: In each operation: The element at index 2 maps to index 1 The element at index 3 maps to index 2