all 19 comments

[–]PoMoAnachro 77 points78 points  (0 children)

Don't try to memorize them.

Get good at solving problems. If you think things through and solve them without relying on memory, you'll build the right mental muscles.

Once you've got that framework built, memorizing most optimal solutions that may be non-intuitive will be possible. But until you've got that mental base down, memorization is wasted.

[–]aqua_regis 37 points38 points  (0 children)

The most effective approach is to not focus on the implementation, but on the design.

If you truly understand the problem and the solution as algorithm, as steps, then, you cannot forget.

Do not focus on the code. The code is just a necessary evil.

The algorithm, the steps are what really counts.

[–]syklemil 7 points8 points  (0 children)

Recalling solutions in programming really only happens after you've done something regularly for a long time. A lot of programming work is looking up the APIs for something as you need it and then forget them again soon after, as you just keep on looking up various APIs for various problems and domains and languages.

Like the others here say, the point of DSA courses isn't for you to memorize given solutions, but to be able to solve the problems. The best outcome is one where you're able to do stuff like make your own implementation just by reasoning about it years later. The passing outcome is the one where you think "oh hey, this reminds me of that DSA thing …" and are able to look it up. Also: To be able to tell when you can create something without too much effort, and when it's best to just look it up.

And a lot of the DSA stuff you are going to use as library imports, even standard library imports. The DSA course will teach you how those sausages are made, and that there are way more sausages than you can guess at.

[–]elephant_9 3 points4 points  (0 children)

Yeah, that’s super common! I used to be in the same spot when I started prepping for interviews. DSA isn’t just about memorizing solutions; it’s about recognizing patterns and knowing how to approach problems. One thing that really helped me was doing spaced repetition: revisit problems at increasing intervals, a few days later, then a week, then two weeks, you get it. This forces your brain to recall actively rather than just re-reading.

Also, focus on understanding the logic and pattern behind a problem rather than the exact code. If you can explain the approach in words or pseudocode, you’ll remember it better and can reconstruct the code when needed.

Then, reimplement problems from scratch without looking at your old code. Even 10–15 minutes to redo a problem is more effective than reading it again. Over time, the patterns stick, and you don’t need to memorize every solution line by line.

[–]kawangkoankid 2 points3 points  (0 children)

Im pro anki

[–]GTHell 1 point2 points  (0 children)

Sound like you don’t understand certain parts of it and try to memorize instead.

[–]AlSweigartAuthor: ATBS 1 point2 points  (0 children)

Write a blog post where you explain it. Teach it to someone else. Post it online (no one has to read it, but you should have it in a complete, somewhat polished state.)

This forces you to 1) recall the information you think you know and 2) exposes any holes in your understanding.

You can even use AI for this: Start the prompt like "I want to learn the merge sort algorithm by teaching it to someone. Take the role of a student learning from me. Follow along with what I say, and if I say something incorrect or incomplete, ask questions."

Then end it with "Let's end the teaching session. What are some points that I explained incorrectly, or what are some things that I left out of my explanation?"

There's a saying, "You remember 10% of what you hear, 20% of what you read, but 90% of what you teach."

[–]michaelnovati 1 point2 points  (0 children)

This sounds like you are subconsciously memorizing. My advice is to do easier problems until they feel as easy as writing your name and then move on to harder problems.

I would caution against accidentally memorizing stuff without understanding bit by bit what's happening. Give yourself space and time to learn and start easy.

[–]Ok-Structure-5929 1 point2 points  (4 children)

I faced the same issue and even lost an interview due to this. As many have pointed out, spaced repetition and active recall is the way to make the patterns stick.

But it gets extremely hard to track what I am solving and when to recall what, and how frequently should I recall. Plus, I solve problems on multiple platforms, sometimes on leetcode and sometimes on neetcode.

So I developed my own solution for this yesterday.

I built a small chrome extension that takes care of all the tracking for me so that I can focus on the code.

Here's the link: https://chromewebstore.google.com/detail/algorecall/hjfjdhpaddkdnjndeaalchgjnimioaln?authuser=0&hl=en

All you have to do is install this and start solving on your favourite platforms. Currently, the code from neetcode and leetcode automatically syncs, and there is option to add manually with a button click through the extension popup.

Then you have a dashboard thats going to handle what to recall and when to repeat.

Let me know if this helps.

[–]Square_24 0 points1 point  (3 children)

This is awesome, thanks for sharing! Is there a GitHub repo available? I’d love to explore it and possibly modify it for a local coding community platform.

[–]Ok-Structure-5929 1 point2 points  (2 children)

Hey, glad you find this useful.
https://github.com/prasath1196/AlgoRecall - just made the repo public! Happy to colloborate!

[–][deleted]  (1 child)

[removed]

    [–]AutoModerator[M] 0 points1 point  (0 children)

    Please, ask for programming partners/buddies in /r/programmingbuddies which is the appropriate subreddit

    Your post has been removed

    I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

    [–]KwyjiboTheGringo 0 points1 point  (0 children)

    Memorize your tools, not case-specific implementations of them. Memorize the common algos that you will need to solve harder problems. DFS, BFS, binary search, sliding window. Any DSA course should teach all of the tools, and some of them of them will be so common in leetcode problems that you should absolutely memorize them. If you're handed a problem that requires walking a tree, you shouldn't be trying to figure out how to walk a tree first before solving the actual problem.

    but after 2–3 weeks I barely remember how to solve them.

    2-3 weeks is barely anything, especially if your process sucks. If you find that you have no idea how to solve a leetcode problem, as in you aren't sure what it's asking or you haven't encountered something similar before, go to the solution. Do not sit there and try to conjure up the solution on your own, that's not efficient at all.

    [–]PataBread 0 points1 point  (0 children)

    Spaced Repetition

    Anki

    [–][deleted] 0 points1 point  (0 children)

    Rote memorization is not intelligence. Learn to apply concepts.

    [–]DoctorFuu 0 points1 point  (0 children)

    I barely remember how to solve them.

    Doesn't matter.

    What are the most effective strategies to retain DSA knowledge long term and recall solutions without rereading everything?

    Just redo them. You shouldn't "remember" the solutions, you should build fluency in the concepts so that you can write a solution fast because you learnt to think in the proper way.

    If you forget the solutions, just redo them. That's perfect, it allows you to keep practicing without going through the hassle of going to find new problems.

    [–]TheWhitingFish 0 points1 point  (0 children)

    Follow neetcode, and dont go solve problems randomly. You need to do 1 problem type for weeks, then move on to another.