Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Day 293 #599

Closed
vaskoz opened this issue Jun 11, 2019 · 0 comments · Fixed by #736
Closed

Day 293 #599

vaskoz opened this issue Jun 11, 2019 · 0 comments · Fixed by #736
Assignees

Comments

@vaskoz
Copy link
Owner

vaskoz commented Jun 11, 2019

Good morning! Here's your coding interview problem for today.

This problem was asked by Uber.

You have N stones 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 1 unit 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 stones [1, 1, 3, 3, 2, 1], the optimal solution is to pay 2 to create [0, 1, 2, 3, 2, 1].

@vaskoz vaskoz self-assigned this Jun 11, 2019
@vaskoz vaskoz mentioned this issue Oct 22, 2019
@vaskoz vaskoz mentioned this issue Jan 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant