BETA

Difficulty Level: Easy

Submissions: 753 Accuracy:

19.39%

Convert to Strictly increasing array
       

Given an array of n integers. Write a program to find minimum number of operations in array so that array is strictly increasing. In strictly increasing array A[i] < A[i+1].

Input : arr[] = { 1, 2, 6, 5, 4}
Output : 2
Operation is:
We can change a[2] to any value between 2 and 5 (this costs 1 operation)
and a[4] to any value greater then 5. 
so transformed array is 1 2 3 5 6.

Input:
First line consists of T test cases. First line of every line test case consists of N, denoting number of elements in array. Second line of every test case consists of array elements.

Output:
Single line output, print the minimum operations to be done to make it strictly increasing.

Constraints:
1<=T<=100
1<=N<=1000

Example:
Input:

2
6
1 2 3 6 5 4
7
1 2 3 4 5 6 7
Output:
2
0

** For More Input/Output Examples Use 'Expected Output' option **

Contributor: Saksham Raj Seth

Set Default Code

					   
It is recommended to 'Compile & Test' your code before clicking 'Submit'!

Compilation/Execution Result:

Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.