Brick Wall - Leetcode 554 - Python

แชร์
ฝัง
  • เผยแพร่เมื่อ 4 ธ.ค. 2024

ความคิดเห็น • 26

  • @amandubey5287
    @amandubey5287 2 ปีที่แล้ว +18

    This is just genius, the moment you said to only take the gaps as keys I could figure out the algorithm, things like these helps one to remember the logic behind way quicker. Thanks for the content

  • @sunnilabeouf
    @sunnilabeouf 3 ปีที่แล้ว +6

    I love this explanation, super easy to follow

  • @NeetCode
    @NeetCode  3 ปีที่แล้ว +6

    Feel free to suggest problems below! :~)

    • @agastyateja6300
      @agastyateja6300 3 ปีที่แล้ว

      Prims and Krushkal's alorithms?

    • @ddonddon2430
      @ddonddon2430 3 ปีที่แล้ว +1

      Sliding puzzle

    • @chiraagpala3243
      @chiraagpala3243 3 ปีที่แล้ว +1

      85. Maximal Rectangle
      134. Gas Station

    • @ZQutui
      @ZQutui 3 ปีที่แล้ว

      I'd like to see more hard leetcode problems

    • @jayeshnagarkar7131
      @jayeshnagarkar7131 2 ปีที่แล้ว

      pizza cut

  • @churchilmoondra3351
    @churchilmoondra3351 2 ปีที่แล้ว +3

    Liked the video before even watching it. The best channel for competitive coding questions. ❤

  • @deathbombs
    @deathbombs 2 ปีที่แล้ว

    initial thought: Maximize count the gaps in the wall of bricks - hashpam key is x, value is number of gaps

  • @MsSkip60
    @MsSkip60 3 ปีที่แล้ว +4

    yet another top notch content from NeetCode!

  • @adityadhikle9473
    @adityadhikle9473 2 ปีที่แล้ว +1

    Ohh man. I tried my level best for this problem passed 78 test cases, spent over 1.5 hrs on this problem. Got time limit exceeded on 79th case. Came here (my fav TH-camr). Now I am laughing after hearing the logic.

  • @BarneyBing883
    @BarneyBing883 2 ปีที่แล้ว +2

    I think this can also be solved with prefix arrays. Whenever the prefix sum at any position of two arrays are the same, that means drawing a line through them at that position will NOT cut through them. So we just have to see at which position, the prefix sum of the MOST number of arrays is the same, and the answer is the remaining bricks (because we will cut through them)

    • @LeakCentral
      @LeakCentral 10 หลายเดือนก่อน

      i believe this is just a variation of prefix sum

  • @ShubhamSingh-vh1vw
    @ShubhamSingh-vh1vw ปีที่แล้ว +2

    This question made no sense until your video explanation was seen

  • @ankurbhambri9199
    @ankurbhambri9199 11 หลายเดือนก่อน

    Excellent explanation bro.

  • @leon10982
    @leon10982 6 หลายเดือนก่อน

    super clear. Thanks

  • @danielsun716
    @danielsun716 ปีที่แล้ว +1

    One question: why cannot we set countGap = collections.defaultdict(int)?
    I guess the reason is defaultdict is only for nonexistent keys not for nonexistent values. Is that correct?

  • @VijayKiran225
    @VijayKiran225 2 ปีที่แล้ว

    one of the few qns which i liked

  • @sanooosai
    @sanooosai 3 หลายเดือนก่อน

    thank you sir

  • @fabriciosuarte
    @fabriciosuarte 2 ปีที่แล้ว +1

    Amazing content / explanation. Would love to see such kind of explanation to the second part of the "Lego Blocks" Hackerrank problem. Only found poor explanations... Anyway, congrats! I'm following the channel now :)

  • @muskangupta1977
    @muskangupta1977 3 ปีที่แล้ว

    The skyline problem

  • @deathbombs
    @deathbombs 2 ปีที่แล้ว

    Sometimes your explanation of problem gives away answer to question - it's too clear. You're taking away our need to practice reaading