Given an array of integers ,the cost to change an element is abs(newvalue — initialvalue) .Determine the **minimum cost** to sort the array either ascending or descending .↵
↵
1<=n<=1e3↵
1<=arr[i]<=1e9↵
↵
I couldnt find its solution after so much brainstorming can anyone help me out with its solution?↵
↵
![question](/predownloaded/f2/f1/f2f119fbb35903d45871beae8e90bb41bae5f420.jpg)
↵
1<=n<=1e3↵
1<=arr[i]<=1e9↵
↵
I couldnt find its solution after so much brainstorming can anyone help me out with its solution?↵
↵
![question](/predownloaded/f2/f1/f2f119fbb35903d45871beae8e90bb41bae5f420.jpg)