ACM GIM
https://linktr.ee/bingacm
Everything is there!
I LOVE QR CODES!!!
OUR EBOARD
PUTTING THEM ALL ON BLAST!!!
woooooooooo
President
Vice President
Treasurer
Secretary
Webmaster
Social Media Manager
Project Manager
Project Manager
Project Manager
Senior Advisor
Senior Advisor
What is ACM?
BINGHAMTON ACM
Competitions
Workshops
Projects Division
Executive Board
Brute Force
Sample Problem
You are given an integer array height of length n. There are n vertical lines drawn such that the two endpoints of the ith 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.
My Solution
class Solution:
def maxArea(self, height: List[int]) -> int:
maxArea = 0
left, right = 0, len(height) - 1
while left < right:
area = (right - left) * min(height[left], height[right])
if area > maxArea:
maxArea = area
if height[left] > height[right]:
right -= 1
else: left += 1
return maxArea