What would be the solution to below question
Anonymous User
516

There are multiple blocks of varying sizes. The job is to paint the blocks. Below are the constraint:

  1. 1 unit of block takes 1 amount of time.
  2. the continuous blocks can be painted in one go hence we can say to for example to paint 3 contiguous blocks of size 1 takes 1 unit of time.
  3. If the blocks are not contiguous we need to account for time of invidual units.

For eaxmple:

[4,4,4,4] ->. This take 4 unit of time hence the output it 4
[5,1,2,3] -> This takes 1 unit to paint 1 unit of all 4 blocks+(4 units of 1st block+2 units of last two blocks)+1 units of last block ==> 8

Comments (2)