This damn problem on LeetCode. Reading and trying to understand the solutions. But this video is the best one and the one finally understand it. Thank you very much man.
thank you, very well and simply explained, I'm writing my final school leaving exam soon, and I'm extending computer science(in my country you can choose extended additional subjects).
Great explanation. Thank you. "Prefix sum" kept coming in the context of loop-unrollling and I'm like "back up. what's a prefix sum???" Now I get it and can move on!
What I'm struggling with is understanding how and when to use it for things beyond the prefix sum algo itself. eg - I know that facebook coding puzzle Director of Photography can be used to solve it, but I still don't really understand how to spot the use cases.
Hi Mike great video, So i am like little confused if it is given to calculate sum between 2 indexes except 0 i.e sum between 3 to 5 index why do we do PS[5] - PS[3-1] and not PS[5] - PS[3]
It's because sometimes people like to start their prefix sum as value 0 first or not. Let's say you have: Arr: [1, 2, 3, 4, 5, 6] Pref: [1, 3,6, 10, 15, 21] Sum index 3 to 5: 4 + 5 + 6 = 15 To get that you need to do: 21 - 6 = pref[5] - pref[2] But if you start your prefix sum at 0: Pref: [0, 1, 3, 6, 10, 15, 21] 21 - 6 = pref[5 + 1] - pref[3] It depends how you want to start your prefix sum
This damn problem on LeetCode. Reading and trying to understand the solutions. But this video is the best one and the one finally understand it. Thank you very much man.
thank you, very well and simply explained, I'm writing my final school leaving exam soon, and I'm extending computer science(in my country you can choose extended additional subjects).
You explained that really good, thank you! It helped me a lot :D
No problem!
Finally someone who explains this simple
Great explanation. Thank you. "Prefix sum" kept coming in the context of loop-unrollling and I'm like "back up. what's a prefix sum???" Now I get it and can move on!
In which course and in which year you are???
What is loop unrolling?
loop unrolling is when you try to unroll the loop in assembly to make it more efficient, that's super exhausting to do though
This was explained extremely well. Thank you very much !!
Glad it was helpful!
Giving a codeforces contest ,this really came in clutch,Great work!!
damn.. I just want to grab that pencil right off his hands, sharpen it. Then give it back to him!
Thanks for this, finally I got to know what prefix sum is and helps me solve leetcode 370!
What I'm struggling with is understanding how and when to use it for things beyond the prefix sum algo itself. eg - I know that facebook coding puzzle Director of Photography can be used to solve it, but I still don't really understand how to spot the use cases.
Amazing explanation Michael. Great job. Subscribed to your channel.
thanks!!
Great explanation thank you!
love you bro
love you too man!
Thanks brother! That was really cool!
You bet!
So it's just caching / memoizing for one speicific function (getting prev sum) basically
This video was very helpful, thank you!
Glad it was helpful!
So prefix sum is basically a version of sliding window technique
great explanation
Thank you!!
@@MiketheCoder you're such a great teacher explaining it!
thanks bro
Hi Mike great video, So i am like little confused if it is given to calculate sum between 2 indexes except 0 i.e sum between 3 to 5 index why do we do PS[5] - PS[3-1] and not PS[5] - PS[3]
It's because sometimes people like to start their prefix sum as value 0 first or not.
Let's say you have:
Arr: [1, 2, 3, 4, 5, 6]
Pref: [1, 3,6, 10, 15, 21]
Sum index 3 to 5:
4 + 5 + 6 = 15
To get that you need to do: 21 - 6 = pref[5] - pref[2]
But if you start your prefix sum at 0:
Pref: [0, 1, 3, 6, 10, 15, 21]
21 - 6 = pref[5 + 1] - pref[3]
It depends how you want to start your prefix sum
@@MiketheCoder Isn't our prefixSum would have length > than our original array if we start from 0?
@@atulkrjha Yup, it really depends on the individual how they want to code it.
Thanks!
noice😊
man ily
Saved me. Thank you
Glad it helped!
Can you also make a video on implementing a parallel version of Prefix Sum?
With multithreading???? Maybe. I’ll think about it.
great explanation
Glad you think so!