
JumpyJellybean
25moby
I'm practicing Dsa for 3 months now.Having a doubt,how to approach a problem involving subarrays
WHICH APPROACH TO CHOSE AND WHY? 1.Prefix sum 2 Kadane's algo. 3.Sliding window 4.Hashing
25mo ago

MagicalQuokka
25mo
Do quick dry runs on paper and finally choose the one which is working. Over time, you'll get better at picking the correct approach in one go.
Sliding window problems are very easy to identify due to their sliding nature.
Based on number of problems in categories, I think probability-wise it makes sense to go for hashing > something using stacks > two pointers > prefix sum > Kadane's
Discover more
Curated from across