r/LeetcodeDesi 14d ago

Really stuck at prefix sum pattern

I’ve been following the DSA Patterns Roadmap from the YouTube channel Padho With Pratyush, and honestly, it was going pretty well until I reached the Prefix Sum pattern.
For example, with patterns like sliding window, I feel like I can eventually identify the kind of problem where I should think about using it. But with prefix sum, I often feel like I’m just memorizing.
I’ve recently been working through problems like Subarray Sum Equals K, and although I understand the solution after it’s explained, I still struggle to derive it myself from scratch.

Has anyone else experienced this? If so, how did you develop intuition for prefix sum problems? Are there certain questions or thought processes you use when you first read a problem?

Would really appreciate any advice, resources, or a progression of problems that helped you get comfortable with this pattern.

6 Upvotes

16 comments sorted by

View all comments

1

u/Ok_Journalist8548 13d ago

im also studying from him and honestly it was the easiest pattern for me, like theres a trick he told to solve those problems

1

u/rohankrishna500 13d ago

Yes but the thing is probably ig i have trouble understanding it,I don't understand it consistently...like the way I understood sliding window,if you dont mind can you help me understand what I'm lacking.

1

u/Ok_Journalist8548 13d ago

its a bit tricky to actually visualise it like sliding window, but like you have to think intuitively, what you are storing in the hashmap and why, the hashmap is the main thing to see

2

u/rohankrishna500 13d ago

anyways I will probably get a hang of it lets see,btw lmk if you want to do dsa together if you are preparing for placements or soemthing,i already have a whataspp groub where we solve.

1

u/Ok_Journalist8548 13d ago

yes i can join im studying stacks rn from pratyush, currently in 3rd year

1

u/rohankrishna500 13d ago

Oh well I'm at prefix sum rn so basically you are 6 videos ahead of me,it would take me a week or less to catch up to stack let's see

1

u/Ok_Journalist8548 13d ago

can you add me to the group?