Back to problems

Container With Most Water II

Algorithm · Apple · Medium

Maximum Water Container You receive an integer array height, where height[i] gives the height of the bar at index i. Select any pair of bars as the sides of a container, then return the greatest volume of water that any such container can hold. Examples Example 1: Input: height = [3,8,4,6,5,7,2,9] Output: 48 Explanation: Choosing the bars of heights 8 and 9 creates a container with width 6, so it holds min(8, 9) * 6 = 48 units of water. Example 2: Input: height = [5,5,5]…

Checking your access…