nishantdhamija41's blog

By nishantdhamija41, history, 2 months ago, In English

Give a height of a rectangular wall as H and an array of bricks, where each index i is from (0<=i<length of the array) represent the colour of brick and each element of array represents number of bricks of that colour

for example H=3 and arr=[2,1,2,1,3] means colour of 0 has 2 bricks

colour of 1 has 1 bricks

colour of 2 has 2 bricks

colour of 3 has 1 bricks

colour of 4 has 3 bricks.

Now there are some rules for creating a wall

  1. a wall height height should not be greater than H

  2. each column of wall should contain different color bricks

Find the maximum area of rectangular wall

for H=3 and arr=[2,1,2,1,3] the ans=9; output=>

2 2 3

0 0 1

4 4 4

0<=H,N<=1E5 1<=arr[i]<=1e11

  • Vote: I like it
  • 0
  • Vote: I do not like it