This was a great explanation. I did not even think about treating each index as an individual column of water. I was traversing the array to look for valleys, which made the code much more complicated.
These videos that end with "there's a more efficient method but it's pretty complicated" I would love to see a separate video anyway to describe it. Heck, a whole playlist of "the harder way" videos. Or at least a Wikipedia link in the description describing the harder, more efficient algorithm.
Thanks for the great explanation. Although this is not a two pointer solution, your explanation helped me understand the intuition behind how a two pointer solution works; the one that dynamically keeps track of the left and right max value. Your videos are great, keep them coming!
class Solution: def trap(self, height: List[int]) -> int: n = len(height) max_L = float('-inf') max_R = float('-inf') L = 0 R = n - 1 count = 0 if n == 0 or n == 1: return 0 while L
Master Data Structures & Algorithms For FREE at AlgoMap.io!
Actually Greg is beyond all of my college professors.
Awe haha
Hey Greg FYI the more I have been watching your videos for a few weeks now and I can say you're a genuis.
Lololol thank you!!
This was a great explanation. I did not even think about treating each index as an individual column of water. I was traversing the array to look for valleys, which made the code much more complicated.
Thanks for explaining this problem in such an easy way!
Glad to hear it 😊
Great explanation, you made this hard problem really easy to understand
Oh I'm really happy to hear that
These videos that end with "there's a more efficient method but it's pretty complicated" I would love to see a separate video anyway to describe it. Heck, a whole playlist of "the harder way" videos. Or at least a Wikipedia link in the description describing the harder, more efficient algorithm.
Sorry about that!!
Thanks for the great explanation. Although this is not a two pointer solution, your explanation helped me understand the intuition behind how a two pointer solution works; the one that dynamically keeps track of the left and right max value. Your videos are great, keep them coming!
awesome visualization! would love to see the O(1) space solution too.
Love the way you explain
Great Explanation !! keep it up
very nice explanation! cheers
Seems like you should take "2 Pointers" out of the video title.
Nah, that's the name of the algorithm
@@GregHogg No, this is a 1 pointer solution. The solution you allude to at the end of the video is a 2 pointer solution.
if you were not going to show 2 pointers then why did you have it in the title.
heyy man! great work, i love you!!!
Thank you for saying it's stupidity hard 😂😂
Thank man, it is really helpful keep up the Good work. ☺
thanks man
My pleasure, thank you so much for your support!
class Solution:
def trap(self, height: List[int]) -> int:
n = len(height)
max_L = float('-inf')
max_R = float('-inf')
L = 0
R = n - 1
count = 0
if n == 0 or n == 1:
return 0
while L
This is not an optimal solution, and you are misguiding
this was not two pointers technically
This is not the best solution, and it's not a two-pointer approach either!!