Container with most water
HardYou're given an array of non-negative integers that represent various possible heights of a container.
Find the max area of a container, where:
- The width is the distance between the numbers in the input array
- And the height is the largest possible height on both sides of the contianer.
For example, given the heights
[3, 9, 2, 7, 4, 6]
, the max container area is 24
, shown by the shaded area below:Try it
Solution
6 Essential Arrays Coding Interview Problems
Master Arrays by trying the coding challenges below.
- 1.Trade stock onceEasy
- 2.AdditionEasy
- 3.Find the smallestEasy
- 4.Reorganize numbersHard
- 5.Maximum subarrayHard
- 6.Container of waterHard