Skip to content

sldeaals/dynamic-programming-exercise

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 

Repository files navigation

dynamic-programming-exercise

Find the minimum cost to make the sequence good

Exercise

There are N towers. The height of the ith tower is H_i. A sequence of towers is Good if there are not any two adjacent towers that have the same heights, i.e for every i (2 ≤ i ≤ N) H_i-1 != H_i condition must hold. You can increase the height of ith tower but it will cost M_i, to increase the height by 1.

Note

You can increase the height of a tower any number of times you want. You have to just minimize the cost to make the sequence of towers Good

How to run

From the computer, choose a browser of your choice that supports the latest web trends, for example Google Chrome. You need to open the browser's code inspector, to do this on your keyboard press the keys For Mac

  • Safari: Cmd(command) + Option + I
  • Chrome: Cmd(command) + Option + C
  • Firefox: Cmd(command) + Option + C For Windows
  • Safari: Ctrl(Control) + Shift + I
  • Chrome: Ctrl(Control) + Shift + C
  • Firefox: Ctrl(Control) + Shift + C

Tap the Console tab. Then copy the code from the index.js file and paste it into the console editor. Finally, fill in the parameters N, H, M respectively with the suggested test cases. Verify that the values meet the requirements and constraints of the exercise.

You can also follow the steps below:

  1. Download VSCode to your computer https://code.visualstudio.com/download.
  2. Install NodeJS on your computer https://nodejs.org/en/download/current/.
  3. Clone the repository.
  4. Execute Run with NodeJS from VSCode -> in the terminal -> section "debug section" -> the output will appear.

Additional

In the .zip file you will find the images of the use cases carried out and their respective outputs

About

Find the minimum cost to make the sequence good

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published