Input: arr[] = {1, 2, 3, 4, 5, 6}, S = 2, M = 3
Output: 3
Explanation:
Below are the operations performed:
Operation 1: Select subarray {1, 2} and after increment, array arr[] becomes = {2, 3, 3, 4, 5, 6}.
Operation 2: Select subarray {2, 3} and after increment, array arr[] becomes = {3, 4, 3, 4, 5, 6}.
Operation 3: Select subarray {3, 4} and after increment, array arr[] becomes = {4, 5, 3, 4, 5, 6}.
After the above operations, the minimum element of the array is 3.
Input: arr[] = {3, 5, 2, 7, 3}, S = 3, M = 3
Output: 4
Explanation:
Below are the operations performed:
Operation 1: Select subarray {3, 5, 2} and after increment, array arr[] becomes = {4, 6, 3, 7, 3}.
Operation 2: Select subarray {4, 6, 3} and after increment, array arr[] becomes = {5, 7, 4, 7, 3}.
Operation 3: Select subarray {4, 7, 3} and after increment, array arr[] becomes = {5, 7, 5, 8, 4}.
After the above operations, the minimum element of the array is 4.