Company: Amazon_30july
Difficulty: medium
Calculate Minimum Cost Problem Description You are given an integer array arr of size n . For any array of size at least 2, its cost is the difference between its two minimum values: take the smallest value and the second smallest value, and subtract the smaller from the larger. Find the minimum cost over all subarrays of arr that have a size of at least 2. Note: A subarray is a contiguous part of the array. Complete the function calculateMinimumCost in the editor below. Input Format The first line contains an integer n , the number of elements in arr . Each of the next n lines contains one integer, arr[i] . Output Format Print a single integer on one line: the minimum cost over all subarrays of arr of size at least 2. (inferred - the source states this as a function that returns an integer; on this judge the value is printed to standard output on its own line.) Constraints 2 <= n <= 15000 (inferred - the source states n <= 10^5, but at that size a single input file is up to 1