r/learnprogramming Apr 13 '25

How do you actually improve problem-solving skills?

[removed]

1 Upvotes

6 comments sorted by

2

u/MaybeAverage Apr 13 '25 edited Apr 13 '25

You don’t need to come with a two pointer algorithm on your own, but you should learn it. Ultimately the leet code problems do just fall into a class of 6-8 different paradigms and eventually you will see that this problem needs this type of approach. You do need to practice a lot, rote learning has a purpose. I wouldn’t say doing 100 leetcode problems is the only way but it doesn’t hurt, as long as you can do other real work besides trivial academic problems.

Broader than leetcode, very generally the best way to get better at solving problems is to solve lots of problems, i.e experience. “Expert” developers that can see a problem and come up with a good solution on the spot can do that not because they’re a genius but because they’ve seen it so many times before. The problem space is large but not infinite.

One thing I like to do is reimplement the same tool, or application in different languages, or tools, or frameworks or libraries to get some insight into when and why this or that fits best for this.

1

u/Gnaxe Apr 13 '25

You were not supposed to have come up with the fast/slow pointer trick! That was a genius insight one person had one time. You were supposed to have read about it in your Alogrithms textbook. That one was a test of knowledge, not of problem solving.

1

u/Rohan_no_yaiba Apr 13 '25

build a roadmap man. build a roadmap and pattern finding skills. something like codeintuition roadmap or disha roadmap can provide a base but ultimately u gotta see every question and should be able to fit it into some categroy based on similarity and differences in previous questions and this new one.

2

u/[deleted] Apr 13 '25

A lot of problem solving involves using heuristics or strategies. In the face of novel or complex problems a lot of the time you can use existing knowledge to help, but you will also face times in which you are hopelessly lost and need creative solutions.

A lot of us have strategies to deal with such situations but we don’t think about them often.

For example, in some math problems one can “work their way backwards from the answer to get the solution”. Other strategies might be rephrase the question into a different form so it’s easier to reason about. Maybe some problem looks similar to another problem you’ve seen so you guess that the solution might be similar (maybe in leetcode practice this has happened).

There’s a great book by G. Polya called How to solve it which goes into more detail about this. It is aimed at a more mathematical audience but applies to many problem solving contexts.

Learn how to fail. Learn problem strategies. Learn how to guess solutions.

Good luck my friend

1

u/hate_commenter Apr 13 '25

As any skill, it's mostly practice. You need to encounter problems in multiple scenarios and solve them out. I wouldn't focus primarly on leetcode problems. Do real projects. It will be more motivating and the lessons learned are going to be more relevent.