arrow_back Back to Challenges

#11 Container With Most Water

Medium Acceptance 0%
description

Problem Description

You are given an integer array `height` of length `n`. There are `n` vertical lines drawn such that the two endpoints of the `i`th line are `(i, 0)` and `(i, height[i])`. Find two lines that together with the x-axis form a container, such that the container contains the most water. Return the maximum amount of water a container can store.

checklist Constraints

n == height.length
2 <= n <= 10^5
0 <= height[i] <= 10^4

science Examples

Case #1

In: height = [1,8,6,2,5,4,8,3,7]
Out: 49

Case #2

In: height = [1,1]
Out: 1

Mastery Tags

Arrays Greedy Two Pointers

Hiring Companies

Amazon Google Meta
code

Integrated IDE

code_blocks
Coding
psychology
Aptitude