Question
write a c program where You live on a street with N houses. The houses are labelled as 1 2 . . . N, from
write a c program where You live on a street with N houses. The houses are labelled as 1 2 . . . N, from left to right. You live in the house labelled 1, i.e the left-most house. and you wish to reach the house labelled N i.e. the right-most house.
There is a tunnel present in each house. The tunnel present in the house labelled ii can be used to reach any house labelled j, such that jiAi
Determine the minimum number of houses you can visit in order to reach the right-most house. Input Format
First line will contain T, number of testcases. Then the testcases follow. The first line of each testcase contains a single integer N. The second line of each testcase contains N integers : A1,A2...AN.
It is guaranteed that the sum of the values of N over all the test cases doesn't exceed 310^6. Output Format
For each testcase, output in a single integer equal to the minimum number of houses you can visit in order to reach the right-most house. Constraints
1T50 1N10^5 1Ai10^5
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started