Image Smoother - Leetcode 661 - Python

  Рет қаралды 16,164

NeetCodeIO

NeetCodeIO

Күн бұрын

Пікірлер: 32
@AMakYu
@AMakYu Жыл бұрын
I solved this problem easily on my own the first way, but I was curious what kind of explanation you had with a 16 min video since I didn't think this problem warranted that amount of time. Glad I clicked cause that second solution is amazing. Even when I can solve these on my own, I get value from these videos. Thanks.
@Pegasus02Kr
@Pegasus02Kr Жыл бұрын
amazing. never thought that 255 constraint can be used to such solution
@chugisan6847
@chugisan6847 Жыл бұрын
To get the last 8 bits (at line 14), you can also AND the number with 255. (AND operation is more efficient than mod).
@saulgoodman6710
@saulgoodman6710 Жыл бұрын
At first I thought this problem is nothing just straight forward, but the solution from you made it think how beautiful the solution is and how fundamental we should think, Love your explanation man! keep making these awesome videos of amazing questions.
@syeedtalha1550
@syeedtalha1550 Жыл бұрын
What a lucid explanation! Keep this up!
@MP-ny3ep
@MP-ny3ep Жыл бұрын
Great explanation as always. Thank you for the daily problems.
@theruler1096
@theruler1096 Жыл бұрын
If someone still has any confusion why we are using %256, Lets forget binary, think about a decimal number 23456. What if we want to get the last digit? we use %10. What if 2 digit? We just use %100 (10*10=10^2) , incase of 3 digits %1000 (10*10*10= 10^3) and so on. We get a pattern here. It's like %base^num_of_digits. In this problem we want to get the number that is represented by the last 8 bit. Now, just think in the decimal number way, if we want to get the last 8 digit what should we do? mod by 10^8 (following the pattern). Incase of binary , base =2 and number of digits we want =8. So according to the pattern we have to do %2^8 which is equal to %256. So that's it what we are doing. (Hope it's not making the thing more complicated.) It can be also done by &255 .
@hyperboliq
@hyperboliq 6 ай бұрын
the optimal solution was pretty cool! Bit manipulation questions are so satisfying to solve!
@robin_c24
@robin_c24 8 ай бұрын
i'm amaze how you can come up with the optimal solution.
@a_maxed_out_handle_of_30_chars
@a_maxed_out_handle_of_30_chars Жыл бұрын
this was a good solution, I solved it using the first approach and liked your second approach :)
@EzWorkzzStudios
@EzWorkzzStudios 10 ай бұрын
Amazing naive explanation, helped understanding the rest of the video!
@EzWorkzzStudios
@EzWorkzzStudios 10 ай бұрын
Second solution was sooo intuitive man...
@GCKteamKrispy
@GCKteamKrispy Жыл бұрын
We learnt it in Digital signal processing. Couldn't understand the programming side of it. Thanks
@yasirsyed1443
@yasirsyed1443 Жыл бұрын
amazing explation man! keep it up
@il5083
@il5083 Жыл бұрын
Do we need to come up with the inplace solution in an interview?
@xaviernogueira
@xaviernogueira Жыл бұрын
Nice! More image algos plz
@advier01
@advier01 Жыл бұрын
reminds me of that one keras function
@krzysztofsobocinski2207
@krzysztofsobocinski2207 Жыл бұрын
I just wondering if you could use sums to avoid internal iteration for each element to make the algorithm a bit faster (roughly 9 times faster)
@a_maxed_out_handle_of_30_chars
@a_maxed_out_handle_of_30_chars Жыл бұрын
we don't have to sum the entire row and sums internally iterates using for loop as well
@jamesabasifreke
@jamesabasifreke Жыл бұрын
For the second approach, instead of mod 256 would using logical & 000000011111111 work? To remove everything besides last 8?
@NeetCodeIO
@NeetCodeIO Жыл бұрын
Yeah I think so
@yousrimeftah5768
@yousrimeftah5768 Жыл бұрын
omg!!!! i love it thank you
@jayberry6557
@jayberry6557 Жыл бұрын
Why the memory is same before and after optimization on leetcode? I know in theory it should be less but I wonder why it works differently
@harishdaga1439
@harishdaga1439 Жыл бұрын
never imagine the second solution, thanks-------
@aadarsh8869
@aadarsh8869 Жыл бұрын
This is so good
@shreehari2589
@shreehari2589 Жыл бұрын
Definitely medium problem and there is no way I would come up with the second solution.
@jayberry6557
@jayberry6557 Жыл бұрын
Thank you for dailies!
@ngneerin
@ngneerin Жыл бұрын
could have done with prefix sum too
@CS_n00b
@CS_n00b Жыл бұрын
I don't get why we need to XOR and can't just add?
@khanumar6938
@khanumar6938 Жыл бұрын
i believe thats another way of adding
@nicoluvas8486
@nicoluvas8486 Жыл бұрын
came in by O(1)
@ИгорьКабаков-з4м
@ИгорьКабаков-з4м Жыл бұрын
we actually can use + instead of ^
Buy Two Chocolates - Leetcode 2706 - Python
6:35
NeetCodeIO
Рет қаралды 8 М.
Map of Highest Peak - Leetcode 1765 - Python
14:47
NeetCodeIO
Рет қаралды 4,2 М.
We Attempted The Impossible 😱
00:54
Topper Guild
Рет қаралды 56 МЛН
How to treat Acne💉
00:31
ISSEI / いっせい
Рет қаралды 108 МЛН
黑天使只对C罗有感觉#short #angel #clown
00:39
Super Beauty team
Рет қаралды 36 МЛН
Gas Station - Greedy - Leetcode 134 - Python
15:47
NeetCode
Рет қаралды 152 М.
I made Tetris in C, this is what I learned
15:15
Austin Larsen
Рет қаралды 29 М.
My 10 “Clean” Code Principles (Start These Now)
15:12
Conner Ardman
Рет қаралды 318 М.
Time Needed to Buy Tickets - Leetcode 2073 - Python
12:45
NeetCodeIO
Рет қаралды 15 М.
541 Leetcode problems are NOT enough.
7:12
Sahil & Sarra
Рет қаралды 161 М.
One second to compute the largest Fibonacci number I can
25:55
Sheafification of G
Рет қаралды 455 М.
Koko Eating Bananas - Binary Search - Leetcode 875 - Python
15:12
We Attempted The Impossible 😱
00:54
Topper Guild
Рет қаралды 56 МЛН