Why does answer for input [1, 1, 1, 2, 2] comes out to be 4 ?

  • 0

    I tried the test case [1, 1, 1, 2, 2], expected answer should be 3.
    The leftmost vertical line would be represented by point (0,1) and the rightmost vertical line would be would be represented by point (0, 2)

    I don't understand why suggested answer for the above mentioned input is 4 ?

  • 0

    The answer is to use the leftmost bar and rightmost bar. The leftmost bar is 1 in height, the rightmost bar is 2 in height, so the container is 1 in height effectively, with width 4. 1x4=4

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.