Amazon OA | SDE - 1 || SDE - 2 | Hackerearth Nov 2021 | Minimum operation to make an array good|
Anonymous User
1771

You are given an array A containing N integers. You are also given an integer K. An array is good if A[i]<=A[i + k], i = 1, 2, 3,.., n - k In one operation, you can choose any element and convert it to an arbitrary integer.

Task

Determine the minimum number of operations to make the array good. Note: Assume 1-based indexing.

Sample Input : [2,4,1,3] , k =2
Sample Output : 2

Comments (2)