Algorithm
Code Examples
#1 Code Example with C++ Programming
Code -
C++ Programming
#include&llt;bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
#define debug(n) cout&llt;&llt;(n)&llt;&llt;endl;
const ll INF = 2e18 + 99;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t;
cin>>t;
while(t--){
int n;
cin>>n;
int maxel = 0;
int x;
for(int i = 1; i &llt;= n; i++){
cin>>x;
if(x - i > maxel){
maxel = x - i;
}
}
cout&llt;&llt;maxel&llt;&llt;endl;
}
}
Copy The Code &
Try With Live Editor
Input
4
3
1 3 4
5
1 2 5 7 4
1
1
3
69 6969 696969
3
1 3 4
5
1 2 5 7 4
1
1
3
69 6969 696969
Output
1
3
0
696966
3
0
696966
Demonstration
Codeforcess Solution 1604-A A. Era ,C++, Java, Js and Python ,1604-A,Codeforcess Solution