Recently, some people have asked for advice, so I decided to write a blog.
In this blog, I will talk about my approach to problem-solving, what I think about solving problems, how do I learn techniques, data structures and/or algorithms and others.
Solving is guessing
From my interpretation, solving any problem is just some sort of guessing: making an educated guess of the solution, validating, and repeating until solved. You can speed up the "guessing procedure" by simplifiying the problem to a certain degree by, for example, not considering obviously wrong solutions.
Abstraction and Decomposition
Usually, as soon as I finish reading a problem, I try to simplify it as much as possible. For example, sorting arrays, removing elements, handling simple cases, doing greedy decisions whenever can be done, rearranging formulas to more familiar ones, or decomposing the problems into several independent problems. You might even have to solve a harder problem, just because the harder version has a known solution, or you might reformulate the problem into a completely different one.
Visualisation
In my opinion, visualisation is very helpful when thinking about problems or learning new concepts. It makes it a lot easier to understand some seemingly advanced data structures, or to come up with solutions to problems. For example, you can think of arrays as histograms, think of numbers as a product of prime numbers, if it's a problem related to number theory, or as a binary representation, if the problem is about bitmasks, and so on. These interpretations make it easier to think about the problem.
Ego & Motivation
It is very easy to give up competitive programming, as it might seem difficult to improve, or gain rating in codeforces. When I do competitions, olympiads and contests, I usually enter with the "I have to be first" mindset. That usually keeps my brain busy with trying to solve the problems, and sometimes I even end up solving problems which I thought to be impossible at first. But be aware, this could also put you in a stressful situation, e.g. if you get stuck on some problem with "WA on test 2" verdicts, or ending up as the 10,000th place in a contest. Don't take losses like these too personal, look at them as an opportunity to grow (or just being unlucky): "well, seems like there's a case I haven't considered", "hmm, 10k people know how to solve problem X, so it shouldn't be too hard to learn". Encourage yourself that you can be the best.
Some practical advice
- Don't get stuck thinking about the same idea. Either continue, or change your strategy. Don't be afraid to think about new things.
- Don't force techniques/topics. "is this dp? is this greedy? is this fft?" is usually not a good strategy if your goal is to improve your pattern recognition or improve in general.
- If the problem seems too complex, think about a simpler version of the problem, special cases, e.g. $$$n=1$$$, $$$n=2$$$, $$$k=n$$$, $$$a_i \le 2$$$, the graph is a star, or whatever. You will get an outline of the solution for the general problem.
- Practice. "The simplest solution is usually the right one". Solving lots of problems gives a general understanding on how problems of some kind are solved. It also helps you improve implementation skills, as well as intuition.
P.S. I would like you to share the way you approach problem-solving and/or how you learn new techniques/dsa, so that I get a second opinion. Thanks :P








