3 ms·
Integer array. Applying the next rule, How many jumps are necessary for getting out of the array? Return -1 if never gets out. A[K] = M -> jump to -> A[K+M] =
by quaiks 12y ago
Integer array. Applying the next rule, How many jumps are necessary for getting out of the array? Return -1 if never gets out.
A[K] = M -> jump to -> A[K+M] = L
I don't know If this is enough for understanding the problem.
It's not complex but my solution is going to suck. BTW they like it...
- bjourne 12y agoI think it is, and I have to disagree with you. I think it is a very interesting puzzle for candidates. The array is basically a tree A[K] and the jump is a pointer to its parent node. If the jump is out of the array, A[K] is a root. Your task appears to be to find the max depth of the graph or return -1 if it contains cycles.
- quaiks 12y agoA tree?? I can't see any tree.