Brick Wall - Leetcode 554 - Python

preview_player
Показать описание


0:00 - Read the problem
2:20 - Drawing Explanation
11:05 - Coding Explanation

leetcode 554

#sorted #array #python
Disclosure: Some of the links above may be affiliate links, from which I may earn a small commission.
Рекомендации по теме
Комментарии
Автор

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

amandubey
Автор

Feel free to suggest problems below! :~)

NeetCode
Автор

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

churchilmoondra
Автор

This question made no sense until your video explanation was seen

ShubhamSingh-vhvw
Автор

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 YouTuber). Now I am laughing after hearing the logic.

adityadhikle
Автор

I love this explanation, super easy to follow

sunnilabeouf
Автор

yet another top notch content from NeetCode!

MsSkip
Автор

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

deathbombs
Автор

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)

BarneyBing
Автор

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?

danielsun
Автор

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 :)

fabriciosuarte
Автор

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

deathbombs
visit shbcf.ru