Skip to content

Wine Problem using DP #2430

@nikitakapoor1919

Description

@nikitakapoor1919

Is your feature request related to a problem? Please describe.
Imagine you have a collection of N wines placed next to each other on the shelf. The price of ith wine is pi(Prices of different wines are different). Because wine gets better every year supposing today is year 1, on year y the price would be y*pi i.e y times the value of the initial year. You want to sell all wines but you have to sell one wine per year. One more constraint on each year you are allowed to sell either leftmost or rightmost wine on the shelf. You are not allowed to reorder. You have to find the maximum profit

Describe the solution you'd like
I would like to implement this algorithm using three functions recursion, Top-down DP, bottom-up DP.
Then we can compare the time and space complexity of the above algorithms.

Test Cases:
i/p= [ 2, 3, 5, 1, 4 ]
o/p=50 (max profit)

Please assign me this task.
Thank you.

Metadata

Metadata

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions