This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
You have an array A of size N. | |
You want to move this array to a new array B. | |
You can move one element at a time. | |
Each time you place an element, there is a cost associated with it. | |
The cost of placing an element in B is equal to the difference between the maximum and minimum element in B (after placing the element from A). | |
Example 1 | |
N = 3 | |
A = 3, 1, 9 |