# A Walk Through Fire Hackerearth problem coderinme

##### A Walk Through Fire

Frodo is on the quest to destroy the Lord of the Rings. But Frodo has to cross some dangerous blocks which have fire on them.
There are N blocks and Frodo starts from block 1, which doesn’t have fire.Each i-th block will have fire starting at time 0 and stopping at time T[i]. Of-course, T[1]=0 as Frodo starts from block 1.
Frodo can step on a block only if it has no fire. Therefore, if the fire at block i ends at T[i], he can step on it only at time (T[i]+1) or greater.
Frodo can walk from block i to j in unit time, given that iInput:
First line consists of an integer
t denoting the number of test cases
Each test case begins with
N, number of blocks
Next line consist of
N spaced integers denoting
T[i], the time at which fire on i-th block will stop

Constraints:
1≤t≤10
1≤t≤10
1≤N≤100000

0≤T[i]≤1000000
T[1]=0

Output:
For each test case, print integer denoting minimum time required in a single line

```#include <iostream>
#include <vector>
using namespace std;

int main()
{
int t;
cin>>t;
while(t--){
int n,m=0;
cin>>n;
vector <int> v;
for(int i=0; i<n; i++)
{
int x;
cin>>x;
if(m<x)
m=x;
v.push_back(x);
}
cout<<m+1<<endl;
}
return 0;
}```

### hasectic

A web developer(Front end and Back end), and DBA at csdamu.com. Currently working as Salesforce Developer @ Tech Matrix IT Consulting Private Limited. Check me @about.me/s.saifi