This Question Is Asked In A Coding Test. I Am Unable To Find The Solution Till Now
An array of integer is given of size n. We have to make all the equal. For this we can add 1, 2 or 5 to the array element any time and to any element. We have to find minimum no of operation to do so?
For example Array. 2 2 3 7
Output should be 2
Explanation In first operation we add 1 to 2,2,7 After that array will be as 3 3 3 8 Now in 2nd operation we add 5 to 3,3,3 After that array will be as 8,8,8,8
You could first think about how many operations it would cost to get all values to the highest value in the list.
In a second step you can think if there could be a better solution if you try to reach highest-value+1, highest-value+2, highest-value+3, highest-value+4 .
- → How do I create an array from a single form input box with php on octobercms?
- → Print the output value of an array in twig [OctoberCMS]
- → Declare an array variable to the controller/component [Laravel, October CMS]
- → search array without duplicates React.js
- → Populating array with items from different HTML attributes
- → Get all index value of 1 from binary "01000111"
- → Remove objects from array - Two different approaches, two different results when consulting the length of each array
- → Compare values in two arrays
- → adding multiple polygons in google maps using loops and arrays
- → .split() JS not "splitting" correctly?
- → Vue.js - Binding radio elements of same name to array