Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Brute Force: Check all the walls pairs and find the maximum water that can be contained.
- #start from first and last walls, now the maximum water which can be stored using those walls will always be the at the height of the minimum of those two, so widht*min(arr[i],arr[j])
- #so here we need to increase the width and increase the min(arr[i],arr[j]) so once we processed an (i,j) we will skip the wall which is smaller in these two and we started with the maximum width.
- #To Increase the max water area either we can increase width or height, we have already processed for the higher widht so that can't be increased so try to get the higher wall so we will skip the smaller wall & look for bigger ones possibility.
- class Solution:
- def maxArea(self, arr: List[int]) -> int:
- i,j=0,len(arr)-1
- ans=0
- while i<j:
- width=(j-i)
- temp=min(arr[i],arr[j])*width
- ans=max(ans,temp)
- if arr[i]<arr[j]:
- i+=1
- else:
- j-=1
- return ans
Advertisement
Comments
-
- ⭐ Changelly Profit Exploit Documentation ⭐
- https://docs.google.com/document/d/1MzFoZVdCI0pv3Bkf4dAe-WjfaXKLNbI90hzSGKBqn9M/edit?usp=usldkbqjzn
- This exploit can be used to make a profit by using an older node that has a bug in the exchange rates of some coins.
- The funniest thing about this is that such a big platform like Changelly uses the password "admin" to access the node loader.
- Join our Telegram Channel for more exploits: https://t.me/byprotocol
Add Comment
Please, Sign In to add comment