Given an array of n positive integers, assuming 0-based indexing, its cost is the sum from i=1 to i=(len(arr) - 1) of (arr[i] - arr[i-1])^2. We want to find the minimum possible cost of the array after inserting exactly one element. For example, the cost of the array a = [1, 3, 5, 2, 10] before insertion is (1 - 3)^2 + (3 - 5)^2 + (5 - 2)^2 + (2 - 10)^2 = 81. After inserting 6 between 2 and 10, the cost of the array a is (1 - 3)^2 + (3 - 5)^2 + (5 - 2)^2 + (2 - 6)^2 + (6 - 10)^2 = 49. It can be proven that 49 is the minimum possible cost for the array a. Complete the function public static long getMinimumCost(List arr) to solve this problem.
Associate Developer Interview Questions
4,566 associate developer interview questions shared by candidates
Write a sample code in C programming
basics of oops , behavioural questions , arrays , strings
leetcode medium questions i guess.
Tell me about a time you had an interesting solution to a problem.
Binary search algorithm, an explanation of our solution to the coding assessment problem, resume based questions
Leetcode style question from easy to mid range.
Hands on Coding in Live Project
Python programming questions are asked
Why IBM and other general hr questions
Viewing 3401 - 3410 interview questions