All submissions for this problem are available.
Very similar to the childhood game kit-kit, Chef has found a game bit-bit. In bit-bit, there are N number of boxes with a number written on it. The number specifies, the number of steps that can be taken in forward direction. In case of 0 (zero) written on the box, no forward steps can be taken. The game starts with the player being on the first box, and he needs to reach the last box.
Chef wants to do it in minimum number of steps. Help Chef in the same.
For each test case, Print the minimum number of steps.
- 1 ≤ T ≤ 10
- 1 ≤ N ≤ 105
- 1 ≤ Ai ≤ 1000
Input: 1 4 2 0 3 4 Output: 2
The path is 2-> 3 -> 4.
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, SCM chicken, PYP3, CLOJ, FS|
Fetching successful submissions
If you are still having problems, see a sample solution here.