Company: HCLTech
Difficulty: medium
Minimize Array Cost Problem Description You are given an array arr of n positive integers (0-based indexing). The cost of an array is the sum of the squared differences of its adjacent elements: cost(arr) = (arr[1] - arr[0])^2 + (arr[2] - arr[1])^2 + ... + (arr[len(arr)-1] - arr[len(arr)-2])^2 An array with a single element has cost 0 . Insert exactly one integer at any position of the array (before the first element, between two adjacent elements, or after the last element) so that the cost of the resulting array is as small as possible. Determine that minimum possible cost. Complete the function getMinimumCost(arr) , which receives the array arr and returns the minimum possible cost after exactly one insertion. Input Format Read from standard input. n arr[0] arr[1] ... arr[n-1] Line 1 contains the integer n , the number of elements. Each of the next n lines contains one integer: line i + 2 holds arr[i] . Output Format Print one integer: the minimum possible cost of the array after in