11. Container With Most Water - LeetCode - Python - Tamil

preview_player
Показать описание
#CodeMeal #python #leetcode #coding #container #water #most #ContainerWithMostWater #11 #mostwater #twopointer #tamil

Рекомендации по теме
Комментарии
Автор

Hi I have recently come across your you tube videos in solving the leetcode problems definitely ur problem explanation are really good na keep on going

AbishaJ-ul
Автор

bro leetcode series useful ah iruku continue panuga

Hariprasath-wv
Автор

i have another doubt bro for the while loop the condition is l<r, this condition is statisfied when the array is sorted right? or if im not wrong l and r will take the index value or the array value?

areuokeybabygang
Автор

Hi bro, first iteration la if condition true aaguthu, so else and elif is skipped, so how the pointer are get adjusted, because the adjustment of l and r in else and elif, that' condition are false in first iteration so how it go for next iteration

Udhayphoto
Автор

anna i have a doubt....neenga sonninga two pointer sorted array ku tha use panna mudiyu nu aprm epdi ithuku use pandringa can you clear me

vinothini-pl
Автор

first I would read the question in leetcode myself and it would;t even makes sense and then I come here get the understanding and I will do the coding then I will check your coding part and analyse this way I'm trying to solve the problem and getting the code closer to the your ans which give me confidence to go on.

btw love your videos :)

my code

def maxArea(height) -> int:
l = 0
r = len(height) - 1
area = 0

while l < r :

min_height = 0
dist = r - l

min_height = min(height[r], height[l])
tot = dist * min_height
print(tot, area)

if tot > area:
area = tot

if height[l] > height[r]:
r -= 1
else:
l += 1

return area


height = [1, 8, 6, 2, 5, 4, 8, 3, 7]
maxArea(height)

vignxs
Автор

Bro, I think you should be using if instead of elif for checking height[l] > height [r], because even if the f > res, we update the result and then we still have to continue the while loop right ?
(I might be wrong, but "elif" won't be executed if the "if" statement passes right ? )

Raajeshwaran
Автор

bro.. this code shows the run time error.. can you resolve it?

gjr_
visit shbcf.ru