I feel the same, I can't really relate to the idea that leetcode style problems are about "memorize and regurgitate". Maybe you need to know a few basic data structures, but beyond that it feels like you can just figure things out as you go. Is the classic "invert a binary tree" actually so hard to figure out that you could only solve the problem if you had memorized the solution beforehand?
Agreed. My skill for straight up memorizing things is terrible. I dont know how one could do it with leetcode, especially since a lot of problems are “kinda similar, but with one major change that alters the entire approach.” To me, it is mindblowing to even attempt memorizing it at all. I will never understand how one can even attempt to deal with leetcode by memorization.
For me, leetcode just helped with intuition for tools and approaches. When i see a problem, i think “ok what are the constraints? With this in mind, would it be better solved using graph structures or some recursion? Which would be cleaner? Which would be better for memory? What about speed? Etc.”, and from that point, it is just pure problem solving on the spot. Occasionally, i get those “oh, I remember solving a problem that wasnt quite like that at all, but it reminds me of it on fundamental level, and back then i remember using a recursive approach (though i dont even remember the problem at all anymore). What would happen if i approached this current problem the same way?”.
It just straight up helps me keep going and coming up with possible approaches to consider, as well as analyze and evaluate them, rather than being frozen on a problem for a while. And those “approaches” aren’t specific to a single unique problem, they apply on a fundamental level to a lot of other completely unrelated problems.
Yes, I’ve seen double nested for-loops in production code, which later became a performance bottleneck that had to be addressed. The issue is that “the problem” in that case was something that can be solved in linear time, and it would be a leetcode easy problem level of difficulty. It instantly jumped out to me wildly the second i saw that piece of code, but no original code reviewers were concerned. This is the kind of stuff leetcode is supposed to help with. Not with solving specific problems, but giving you a solid toolset and intuition on fundamental screwups and how to avoid them and spot them quickly in bajillion different situations that dont look the same at all.
Memorization won’t be your friend here, unless you possess one of those photographic memory brains that remembers the faces of every single person they’ve ever encountered. If you are going into leetcode with the mindset of “i am trying to memorize as many problem solutions as i can”, you are gonna have an awful time.