Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

container with most water python code leetcode

def maxArea(height: List[int]) -> int:
    # This variable will store the maximum area
    max_area = -maxsize
    # Left and right pointers
    left = 0
    right = len(height) - 1
    # Loop until the two pointers meet
    while left < right:
        # Shorter of the two lines
        shorter_line = min(height[left], height[right])
        max_area = max(max_area, shorter_line * (right - left))
        # If there is a longer vertical line present
        if height[left] < height[right]:
            left += 1
        else:
            right -= 1
    return max_area
Comment

PREVIOUS NEXT
Code Example
Python :: django pre_save get old instance 
Python :: geopandas dataframe to ogr layer 
Python :: stackoverflow python 
Python :: end without space in python 
Python :: mid-point circle drawing 
Python :: pandas get highest values column 
Python :: ide for python 
Python :: python indent print 
Python :: list length python 
Python :: sklearn tree visualization 
Python :: how to use custom activity in discord.py 
Python :: python greater than dunder 
Python :: installing intel-numpy 
Python :: management command in django 
Python :: how to check if element is in list python 
Python :: pandas trim string of all cells 
Python :: :: python 
Python :: Working with WTForms FieldList 
Python :: .defaultdict 
Python :: xlrd python read excel 
Python :: where is python installed windows 
Python :: datetime64 ns to date python 
Python :: html element python 
Python :: python lock file 
Python :: how to repeat a row in pandas 
Python :: py search and get objects from array 
Python :: open multiple urls 
Python :: tensorflow create custom initializer 
Python :: pytesseract.image_to_data(img output_type=output.dict) 
Python :: change every element of list python with map 
ADD CONTENT
Topic
Content
Source link
Name
3+8 =