Count Operations
Count Operations is a Wells_fargo coding interview problem asked in Wells_fargo interviews. Given a permutation p of 1..n and any array of n distinct elements, repeatedly apply the permutation operation temp_arr[i] = arr[p[i]]. Determine the minimum number of operations (at least 1) needed to restore the original array, and return the count modulo 1e9+7. Classic interview question.
Example
Unlock to view complete problem details
and practice with sample input/output
Was this article helpful?
View Test Cases & Run Code requires membership
Input Variables
Execution Result:
