Nemo's Jump

0

0 votes
Problem

Nemo is a fish and wants to reach her home but she has a series of lakes to go through to reach her destination help us find whether she will be able to reach her home or not.

Explanation:
To reach her home Nemo has to jump across the lakes. every lake has a size factor which determines how far Nemo will be able to jump from that lake.
i:e if the lake has a size factor of 4 than from that lake Nemo will be able to jump "upto" 4 lakes.


You are given an array of size factors of the lakes with Nemo starting at lake 1 and her home at lake N.


Input:
The first line of the input contains a single integer T no. of testcases.
The second line of the input contains a single integer N the total no. of lakes.
Next line of input contains N space seperated integers A1 , A2 , A3 ..... AN the size factors of the lakes respectively.

Output:
Print a single integer 1 or 0.
1 - if Nemo can reach home.
0 - if Nemo can't reach home.

Costraints:

1<= T <= 10
1 <= N <= 10^4
0 <= Ai <= 10^4 where i∈[1,N]

Time Limit: 5
Memory Limit: 256
Source Limit:
Explanation

Explanation:

1st - testcase
from the first lake Nemo jumps to 2nd lake and from 2nd lake to the last one.
path - 3(A1)->4(A2)->1(A6)
and hence Output = 1

2nd - testcase
from lake 1 Nemo cannot jump anywhere as the size factor is very small.
therefore Output = 0
 

Editor Image

?