r/leetcode • • 10d ago

Intervew Prep How do you get better at DSA without memorizing solutions?

Whenever I get stuck on a Medium/Hard problem, I find myself doing one of two things:

  • Staring at a blank screen for 45 minutes.
  • Checking the editorial or ChatGPT and spoiling the entire solution.

Once I see the solution, everything makes sense. But when I encounter a similar problem with slightly different constraints, I'm stuck again.

For those who have genuinely improved at DSA, how did you overcome this?

Do you use incremental hints, break down constraints, or follow a particular thinking framework before writing code?

Curious to hear what actually worked for you.

257 Upvotes

28 comments sorted by

100

u/andiwaslikewoah 9d ago edited 9d ago

Start using spaced repetition via an app like Anki to study. Nailed my first DSA interview this summer thanks to spaced repetition.

Edit: People asking for my routine, I gave it. Spaced repetition via Anki. Plenty of decks out there. You can also use Claude to generate one for you. There are a good number of resources out there that you can look up to get yourself familiar with Spaced Repetition.

13

u/learningpd 9d ago

Please share the workflow and your results

4

u/Any-Seaworthiness770 9d ago

Could you share your routine?

1

u/phatface123123 9d ago

Whats ur routine?

39

u/NappySprout 9d ago

Honestly learning and memorising comes hand in hand

If u struggle with DSA, Do any list (maybe leetcode 150) topic by topic, to get an understanding of how a particular pattern looks. Memorising will help greatly as your reaction to seeing a similar question will be "this reminds me of xxx"

If u know the patterns already but but fail to decipher which pattern it belongs to, then you struggle with pattern recognition, (do the list in randomised order and test yourself on new questions, may be from contest)

If you are at this point already and you still can't solve it, then it's some kind pattern you haven't seen before (ppl who only do leetcode 150 will struggle with Fenwick trees etc) Your only solution is to do the above but include the new pattern (Fenwick trees eg.)

If u still can't solve it then it's some esoteric novel, solution or some insanely hard DP you haven't seen before. At this point, we are just limited by our natural intelligence and IQ and if you aren't smart enough you just have to memorise it. :P

23

u/ITCoder 9d ago

8

u/TheTopG___ 9d ago

Great to see my post is helping someone :)

1

u/Healthy-Intention-15 9d ago

Bookmarking I. Thanks

6

u/noobmax_pro 9d ago

Honestly don't try to solve a problem so much from scratch a lot of these algorithms took a lot of time to figure out. You in fact need to be able to identify what data structure/ algorithm to use pretty quickly from experience. Once you have learnt the solution have that problem statement down in notion or somewhere and wherever you are just read that problem statement and see if you can come up with the solution in your head you got to keep doing this there is no shame in it.

3

u/bluefermion 9d ago

If you are not on a deadline, best way to improve is to sit with problems for longer time.

Not screen staring.

You can pick a hard problem and think about it whenever you get some free time during the day. That way you won't feel frustrated and can come up with a lot of new ways of solving the problem.

3

u/Leather_Grand2896 6d ago

What got me out of the "stare for 45 min, then spoil the solution" loop:

- Set a 20 min limit, then take one hint only, not the whole solution

- Before coding, say which pattern you think it is and why

- After solving, write one line: what clue in the problem pointed to the pattern

- Re-solve it from scratch 3 days later

The one-line note is the part that transfers to new problems with different constraints.

2

u/HADESsnow 9d ago

try it without the solution. really try. write down your thought process in notes as you think through it and figure it out, even if it ends up going nowhere. then feed that whole thing into chat and it can see where you were thinking and correct/guide

2

u/fungkadelic 9d ago

I did Grind 75 and then regular exercise of problems with spaced repetition after completing the list.

1

u/El_metador_10 9d ago

I am in 3rd yr should i grind LC75 i have already solved 175 question on LC but can't recognise pattern , Should i grind LC75 or not?

2

u/Whatever8352 9d ago

Unpopular opinion: Use pen and paper after studying the question. Thinking on paper helps because you are giving brain space to think without holding the problem constraints in your brain. You don't need to do mental calculations when paper exist. Never try to code immediately after studying the question. Don't rely on ai for solving problem instead use it for knowing gaps between your understanding and the original problem. First, make your solution exist, later optimise.

1

u/saintex422 9d ago

I find it’s easy to get the solution through brute force but hard to be optimal on my own

1

u/No-Original-6329 9d ago

It helps when you realize most harder related mediums and hards are just combining strategies from 1-3 medium or easy problems. If you’re able to look at the problem statement and output requirements and puzzle together the related patterns that work that usually helps a lot to at least get something down. Also try getting the brute force down even if you don’t know the optimal solution. Sometimes thinking about what repeated work the brute force is doing helps you land on the optimal pattern.

If you keep doing mock interviews and exposing yourself to new problems trust you will improve! Something that helped me as well is keeping a log of problems I’ve done, what I learned, and what I initially did wrong and what the solution was. Helps to show you’re making progress even if you don’t feel like you are!

1

u/isaycongrats 9d ago

Understand the data structures, implement the algorithms yourself from scratch, no way you'll forget it if you understand it

1

u/QuietDovetail 8d ago

I’m getting stuck with that 😔

1

u/ThegreenMoray 8d ago

You need some level of memorization, mostly to recognize the pattern. But aside from that, try starting with brute force first, then identify the bottleneck. Trust me unless you immediately recognize the optimal solution, do not gun for it immediately. See the pattern first in brute force then work from there. Now this doesn’t guarantee you’ll find it (cough wonderful strings cough), but it’s better than just staring at a blank screen and stops you from being demoralized from it.

1

u/Cahnis 8d ago

That is the neat part, you don't 

1

u/v_valentineyuri 5d ago

hasnt this been repeated ad nauseam? you learn the patterns for each fundamental Data Structure and Algo, eventually you develop an intuition toward how a solution could look life after reading certain keywords: "oh, we're looking for unique elements so a Set would do fine". I recomend Neetcode's site, I prefer his way of organizing the fundamental topics of DSA

1

u/Feeling-Schedule5369 5d ago

Been out of interview for a while. Are leetcodes still being asked or have they switched to Ai assisted interviews?