Array of integers is a mountain, if:it is strictly increasing in the beginning;after that it is constant;after that it is strictly decreasing.The first block (increasing) and the last block (decreasing) may be absent. It is allowed that both of this blocks are absent.
Answers
Answered by
12
Given an array of n integers. Write a program to find minimum number of changes in array so that array is strictly increasing of integers. In strictly increasing array A[i] < A[i+1] for 0 <= i < n
Examples:
Input : arr[] = { 1, 2, 6, 5, 4}
Output : 2
We can change a[2] to any value
between 2 and 5.
and a[4] to any value greater then 5.
Input : arr[] = { 1, 2, 3, 5, 7, 11 }
Output : 0
Array is already strictly increasing.
Similar questions