Read More »#5
Nstones in a row, and would like to create from them a pyramid. This pyramid should be constructed such that the height of each stone increases by one until reaching the tallest stone, after which the heights decrease by one. In addition, the start and end stones of the pyramid should each be one stone high.
You can change the height of any stone by paying a cost of
1unit to lower its height by
1, as many times as necessary. Given this information, determine the lowest cost method to produce this pyramid.
For example, given the stoneshttps://dailycodingproblem.com
[1, 1, 3, 3, 2, 1], the optimal solution is to pay
[0, 1, 2, 3, 2, 1].
Read More »#4
An imminent hurricane threatens the coastal town of Codeville. If at most two people can fit in a rescue boat, and the maximum weight limit for a given boat is k, determine how many boats will be needed to save everyone.
For example, given a population with weights [100, 200, 150, 80] and a boat limit of 200, the smallest number of boats required will be three.https://dailycodingproblem.com