Google OA
Anonymous User
1371

Minimum operations:
You are given an array A of N non-negative integers and an integer K. You can perform the following operation on this given array any number of times:
• Choose an index i (1<=i<=N), and increase the element at this index by 1

Task Determine the minimum number of operations that needs to be performed, so that every subarray of size 3 or more has a maximum element, greater than or equal to K .

Example:
n=4
k=5
a = [2,1,1,3]
ans = 4

How to do this?

Comments (7)