Prepverse
Dashboard
AI Mock Interviews
Practice
NEW
Contests
Test Series
NEW
Jobs
Sign In
v69806c1
Container With Most Water - Practice - Prepverse 🎓
Toggle Sidebar
Practice
Container With Most Water
Search for mock interviews, practice sets...
⌘
K
Command Palette
Search for a command to run...
Container With Most Water
Prev
Next
Description
Submissions
Container With Most Water
Easy
ARRAY
Two Pointers
GREEDY
You are given an integer array
height
where each element represents the height of a vertical line on the x-axis.
Choose two different lines such that together with the x-axis they form a container.
Return the
maximum amount of water
the container can store.
Note:
- You may not slant the container.
- The width of the container is the distance between the two lines.
The solution should run in
O(n)
time.
Examples
Example 1
Input:
[1,8,6,2,5,4,8,3,7]
Output:
49
Hint 1
Hint 2
Reset
Fullscreen
Loading...
Test Cases
Results
Run
Submit
Test Case 1
Input:
[1,8,6,2,5,4,8,3,7]
Expected Output:
49