Container With Most Water
Updated
Problem statement
Given an array height, where height[i] is the height of a vertical line at position i, choose two lines that together with the horizontal axis form a container.
Return the maximum amount of water the container can hold. The area between indices left and right is (right - left) * min(height[left], height[right]).
Function
maxArea(height: int[]) → intExamples
Example 1
height = [1,8,6,2,5,4,8,3,7]return = 49Indices 1 and 8 have limiting height 7 and width 7.
Example 2
height = [1,1]return = 1The only pair has width and height 1.
Constraints
2 <= height.length <= 100000.0 <= height[i] <= 10000.- The maximum area fits in a signed 32-bit integer.
Source note: Author-written prompt excerpt retained for source fidelity.
More EPAM Phone Screen questions
- Longest Palindromic SubstringPHONE SCREEN · Seen Oct 2026
- Convert an Entry List to a MapPHONE SCREEN · Seen Oct 2026
- Count Array Element FrequenciesPHONE SCREEN · Seen Oct 2026
- Find First and Last Position of Element in Sorted ArrayPHONE SCREEN · Seen Oct 2026
- Group AnagramsPHONE SCREEN · Seen Oct 2026
- Longest Consecutive SequencePHONE SCREEN · Seen Oct 2026
- Max Consecutive Ones IIIPHONE SCREEN · Seen Oct 2026
- Minimum Currency ConversionsPHONE SCREEN · Seen Oct 2026
- Next Greater Element IPHONE SCREEN · Seen Oct 2026
- Partition and Group Values by ParityPHONE SCREEN · Seen Oct 2026
Similar questions at other companies
- Container With Most WaterNuro · PHONE SCREENNuro interview questions
- Rebalance Bank Accounts to a Minimum BalanceRemitly · PHONE SCREENRemitly interview questions
- Container With Most WaterAmazon · PHONE SCREEN · ONSITE INTERVIEW
- Container With Most WaterWayfair · PHONE SCREENWayfair interview questions
- Container With Most WaterMastercard · PHONE SCREENMastercard interview questions
- Assign CookiesExpedia · PHONE SCREEN · ONSITE INTERVIEWExpedia interview questions
- Best Score Switching Between Two Sorted ArraysAdobe · PHONE SCREENAdobe interview questions
- Maximum Easy Tasks After RearrangingIBM · OAIBM interview questions
- Minimum Station Tracks for a Train ScheduleBNSF Railway · ONSITE INTERVIEWBNSF Railway interview questions
- Latest Arrival to Catch a BusAutodesk · OAAutodesk interview questions