Image Smoother - Leetcode 661 - Python

  Рет қаралды 15,201

NeetCodeIO

NeetCodeIO

Күн бұрын

Пікірлер: 32
@AMakYu
@AMakYu 9 ай бұрын
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.
@chugisan6847
@chugisan6847 9 ай бұрын
To get the last 8 bits (at line 14), you can also AND the number with 255. (AND operation is more efficient than mod).
@theruler1096
@theruler1096 9 ай бұрын
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 .
@Pegasus02Kr
@Pegasus02Kr 9 ай бұрын
amazing. never thought that 255 constraint can be used to such solution
@MP-ny3ep
@MP-ny3ep 9 ай бұрын
Great explanation as always. Thank you for the daily problems.
@madvier_8336
@madvier_8336 9 ай бұрын
reminds me of that one keras function
@EzWorkzzStudios
@EzWorkzzStudios 6 ай бұрын
Amazing naive explanation, helped understanding the rest of the video!
@syeedtalha1550
@syeedtalha1550 9 ай бұрын
What a lucid explanation! Keep this up!
@servantofthelord8147
@servantofthelord8147 2 ай бұрын
the optimal solution was pretty cool! Bit manipulation questions are so satisfying to solve!
@robin_c24
@robin_c24 4 ай бұрын
i'm amaze how you can come up with the optimal solution.
@EzWorkzzStudios
@EzWorkzzStudios 6 ай бұрын
Second solution was sooo intuitive man...
@nicoluvas8486
@nicoluvas8486 9 ай бұрын
came in by O(1)
@shreehari2589
@shreehari2589 9 ай бұрын
Definitely medium problem and there is no way I would come up with the second solution.
@jayberry6557
@jayberry6557 9 ай бұрын
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
@saulgoodman6710
@saulgoodman6710 9 ай бұрын
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.
@GCKteamKrispy
@GCKteamKrispy 9 ай бұрын
We learnt it in Digital signal processing. Couldn't understand the programming side of it. Thanks
@a_maxed_out_handle_of_30_chars
@a_maxed_out_handle_of_30_chars 9 ай бұрын
this was a good solution, I solved it using the first approach and liked your second approach :)
@harishdaga1439
@harishdaga1439 9 ай бұрын
never imagine the second solution, thanks-------
@CS_n00b
@CS_n00b 9 ай бұрын
I don't get why we need to XOR and can't just add?
@khanumar6938
@khanumar6938 9 ай бұрын
i believe thats another way of adding
@ngneerin
@ngneerin 9 ай бұрын
could have done with prefix sum too
@jamesabasifreke
@jamesabasifreke 9 ай бұрын
For the second approach, instead of mod 256 would using logical & 000000011111111 work? To remove everything besides last 8?
@NeetCodeIO
@NeetCodeIO 9 ай бұрын
Yeah I think so
@il5083
@il5083 9 ай бұрын
Do we need to come up with the inplace solution in an interview?
@jayberry6557
@jayberry6557 9 ай бұрын
Thank you for dailies!
@ИгорьКабаков-з4м
@ИгорьКабаков-з4м 9 ай бұрын
we actually can use + instead of ^
@yousrimeftah5768
@yousrimeftah5768 9 ай бұрын
omg!!!! i love it thank you
@xaviernogueira
@xaviernogueira 9 ай бұрын
Nice! More image algos plz
@krzysztofsobocinski2207
@krzysztofsobocinski2207 9 ай бұрын
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 9 ай бұрын
we don't have to sum the entire row and sums internally iterates using for loop as well
@yasirsyed1443
@yasirsyed1443 9 ай бұрын
amazing explation man! keep it up
@aadarsh8869
@aadarsh8869 9 ай бұрын
This is so good
Minimum Difficulty of a Job Schedule - Leetcode 1335 - Python
13:41
Microservices are Technical Debt
31:59
NeetCodeIO
Рет қаралды 358 М.
Новый уровень твоей сосиски
00:33
Кушать Хочу
Рет қаралды 5 МЛН
HAH Chaos in the Bathroom 🚽✨ Smart Tools for the Throne 😜
00:49
123 GO! Kevin
Рет қаралды 16 МЛН
WORLD BEST MAGIC SECRETS
00:50
MasomkaMagic
Рет қаралды 54 МЛН
Time Needed to Buy Tickets - Leetcode 2073 - Python
12:45
NeetCodeIO
Рет қаралды 14 М.
How to create L-Systems with Python: A Creative Coding Tutorial
9:31
Code Meowstro
Рет қаралды 1,1 М.
Making an Algorithm Faster
30:08
NeetCodeIO
Рет қаралды 87 М.
Assign Cookies - Leetcode 455 - Python
9:06
NeetCodeIO
Рет қаралды 17 М.
Insert Delete GetRandom O(1) - Leetcode 380 - Python
13:27
NeetCode
Рет қаралды 46 М.
Redundant Connection - Union Find - Leetcode 684 - Python
16:04
Understanding B-Trees: The Data Structure Behind Modern Databases
12:39
I gave 127 interviews. Top 5 Algorithms they asked me.
8:36
Sahil & Sarra
Рет қаралды 656 М.
Новый уровень твоей сосиски
00:33
Кушать Хочу
Рет қаралды 5 МЛН