Anishluke92 / RubySolution

Problem solving using Ruby programming language
0 stars 1 forks source link

Array to visual bar chart #101

Open danielpaul opened 3 years ago

danielpaul commented 3 years ago

This problem was asked by Square.

You are given a histogram consisting of rectangles of different heights. These heights are represented in an input list, such that [1, 3, 2, 5] corresponds to the following diagram:

      x
      x  
  x   x
  x x x
x x x x

Determine the area of the largest rectangle that can be formed only from the bars of the histogram. For the diagram above, for example, this would be six, representing the 2 x 3 area at the bottom right.