Problem Statement | |||||||||||||
*** You may only submit a given problem once - no resubmissions will be accepted. *** You will be given a int[] f describing a function (0-indexed). The value of the function on input k is f[k] (element k of f). To iterate a function you keep calling it on itself. For example, to iterate f 5 times on input x, you would evaluate f(f(f(f(f(x))))).Return the smallest number n larger than bound, such that iterating f n times on x evaluates to x. | |||||||||||||
Definition | |||||||||||||
| |||||||||||||
Constraints | |||||||||||||
- | f will contain between 1 and 50 elements inclusive. | ||||||||||||
- | Each element of f will be between 0 and k-1 inclusive, where k is the number of elements in f. | ||||||||||||
- | bound will be between 0 and 10000 inclusive. | ||||||||||||
- | x will be between 0 and k-1 inclusive, where k is the number of elements in f. | ||||||||||||
- | There will be a solution. | ||||||||||||
Examples | |||||||||||||
0) | |||||||||||||
| |||||||||||||
1) | |||||||||||||
| |||||||||||||
2) | |||||||||||||
| |||||||||||||
3) | |||||||||||||
| |||||||||||||
4) | |||||||||||||
|