Add increments needed to make the 1 st k - 1 elements of this window equal to the kth element of the current window
opsNeeded += ( k - 1 ) * ( ar [ i ] - ar [ i - 1 ] ) NEW_LINE ans = min ( ans , opsNeeded ) NEW_LINE return ans NEW_LINE