Range Sum Query 2D - Immutable - Leetcode 304 - Python

Поділитися
Вставка
  • Опубліковано 8 лис 2024

КОМЕНТАРІ • 39

  • @mohammedafzal4343
    @mohammedafzal4343 Рік тому +7

    At first, it was a little tough to understand, but I watched this video multiple times. Now I fully understood the concept! thanks Neetcode!

  • @blossombabalola1234
    @blossombabalola1234 2 роки тому +27

    Thank you Neet. This concept is a bit difficult to explain but you did a good job!

  • @Mad7K
    @Mad7K 2 роки тому +4

    To be honest at the start I thought I was completely off the mark, but that's exactly how I solved it, thanks for the video.

  • @kariuki6644
    @kariuki6644 2 роки тому +5

    My first time hearing about prefix sum but this made it easier to understand

  • @SkyeTian
    @SkyeTian 2 роки тому +3

    I understand why we are adding a top row since it would be out of bounds when we are calculating prefix sum for the first row (no "above"), but why are we also adding a left column?

  • @aishwaryaranghar3385
    @aishwaryaranghar3385 2 роки тому +6

    Really liking the strategy of posting videos on the streak day!!

  • @dabobrotosarkar7266
    @dabobrotosarkar7266 2 роки тому +3

    Hey Neet! You explain great! I love your videos. Can you make a video about Problem 307. Range Sum Query - Mutable?
    It uses Segment Trees to optimize the algorithm. Would love to see that!

  • @hinatahyuga3038
    @hinatahyuga3038 2 роки тому +1

    thank you so much sir, took me 3 hours to understand it

  • @ይኩነኒ
    @ይኩነኒ Рік тому

    you're de besttttt....Thank youuuuu

  • @krishnalath1266
    @krishnalath1266 2 роки тому +1

    Thank You for such a wonderful explanation....

  • @programmermainul6558
    @programmermainul6558 2 роки тому

    It would be great video. I am jumping on this r8 now. Cheers!

  • @jasdeepsinghgrover2470
    @jasdeepsinghgrover2470 2 роки тому

    This can be generalized to all shapes with vertical or horizontal edges... Then we can apply inclusion exclusion principle

  • @DK-ox7ze
    @DK-ox7ze Рік тому

    What's the logic behind calculating prefix sum for each cell? What's the intuition behind the formula you used?

  • @ainazikmomunalieva3732
    @ainazikmomunalieva3732 2 роки тому

    Thank you! You are a master at explaining!

  • @amosluesun585
    @amosluesun585 2 роки тому

    this is fabulous, nice work

  • @firomsamt7642
    @firomsamt7642 10 місяців тому

    mind blowing!👏

  • @monadastar9393
    @monadastar9393 2 роки тому

    thank you so much

  • @sahaiabhishek
    @sahaiabhishek 10 місяців тому

    Excellent

  • @b9944236
    @b9944236 Рік тому

    Tanks a lot ~

  • @kirillzlobin7135
    @kirillzlobin7135 10 місяців тому

    Amazing

  • @spyboy0076
    @spyboy0076 2 роки тому +9

    I don't know what will i do. I can't think of anything while solving these problems

    • @staffeng
      @staffeng 2 роки тому +12

      I think the only way is to first solve enough problems by learning through videos like this in a systemic manner, like going from one topic to another, practicing them again from memory, and then attempting enough new problems on our own till we are able to solve most of the unseen mediums. This is going to take an insane amount of time but for those like us who are not naturally gifted at this, I think it's the only way.
      @NeetCode - can you create a video on how you got to a stage where you can solve unseen mediums or hards?

    • @gunahawk6893
      @gunahawk6893 2 роки тому

      @@staffeng great 👏

  • @rahulkhatoliya6814
    @rahulkhatoliya6814 2 роки тому

    crystal clear

  • @reapergrim5324
    @reapergrim5324 4 місяці тому

    Line 10 : above = matrix[i][j+1]
    How is this above it should be right ?

  • @pulakammalathy6968
    @pulakammalathy6968 2 роки тому

    cant we compute the prefix matrix in place of the given matrix ?

  • @vasujain1970
    @vasujain1970 2 роки тому

    Interesting video.

  • @rajsuriyang3427
    @rajsuriyang3427 2 роки тому

    one-liner:
    The time limit is exceeding, Why?
    return sum([sum(self.matrix[i:row2+1][0][col1:col2+1]) for i in range(row1,row2+1)])
    Can you explain?

    • @sirmidor
      @sirmidor 2 роки тому +1

      Because you're completely ignoring what the exercise asks: What you typed is not O(1) time complexity for getting a region's sum. Your matrix indexing is also less than optimal: You're already looping over range(row1, row2 + 1), so you would just take self.matrix[i] instead of unnecessarily doing self.matrix[i:row2+1][0] to get a row of the matrix.

  • @Nisha.......
    @Nisha....... 2 роки тому

    Sir, will you please solve leetcode 174?

  • @VidyaBhandary
    @VidyaBhandary 2 роки тому

    Awesome ....

  • @mohithadiyal6083
    @mohithadiyal6083 2 роки тому +1

    No doubt , great video as usual 😀

  • @robertlemiesz7143
    @robertlemiesz7143 6 місяців тому

    I would honestly never ask this in an interview. Kinda feels like you either have seen the problem and know the answer, or need to take significant amount of time deriving it. Tells you nothing about the candidate, except whether or not they do alot of leet code.

  • @krateskim4169
    @krateskim4169 2 роки тому

    nice

  • @theghostwhowalk
    @theghostwhowalk 2 роки тому

    Great video. Mind helping with similar video on Range sum mutable 308 which has update func. Would be great to understand Index tree implementations.

  • @johnvick8861
    @johnvick8861 Рік тому

    within a min i understood .

  • @onepiece1570
    @onepiece1570 2 роки тому

    go

  • @shambhavi6888
    @shambhavi6888 5 місяців тому

    🥹