Minimum cost to find minimum and remove ajdecents till array becomes empty.
Difference between en2 and en3, changed 118 character(s)
**The constraints are 1<n<=10⁵ and a[i]<=10⁹
**↵
**
Now you are given an array a. You task is to find minimum in the current sized array and remove that element and it's adjacent elements. The cost of this operation will be the minimum element choosen. Repeat this step till array becomes empty.
**↵
**
Mathematically, for any i within array limit such that a[i] is minimum of array a, then remove a[i] and if i-1 exists remove a[i-1] and if i+1 exists a[i+1], the cost will be cost+=a[i] , the array will become {a1, a2,...ai-2,ai+2,....an} again find minimum and repeat the same till array becomes empty.
**↵
**NOTE: ELEMENTS NEED NOT TO BE UNIQUE. IF THERE ARE MULTIPLE MINIMIUMS CHOOSE THE ONE WITH LOWEST INDEX**

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en3 English thetwoface 2025-07-09 17:34:13 118
en2 English thetwoface 2025-07-09 15:35:07 6 Tiny change: 'Mathematics for any i' -> 'Mathematically, for any i'
en1 English thetwoface 2025-07-09 15:33:48 665 Initial revision (published)