RithwikG's picture
initial commit
7a8878c
raw
history blame contribute delete
500 Bytes
You are given an integer array $$$a$$$ of length $$$n$$$.You can perform the following operation: choose an element of the array and replace it with any of its neighbor's value.For example, if $$$a=[3, 1, 2]$$$, you can get one of the arrays $$$[3, 3, 2]$$$, $$$[3, 2, 2]$$$ and $$$[1, 1, 2]$$$ using one operation, but not $$$[2, 1, 2$$$] or $$$[3, 4, 2]$$$. Your task is to calculate the minimum possible total sum of the array if you can perform the aforementioned operation at most $$$k$$$ times.