• + 1 comment

    It's just pattern matching, like any other skill.

    Just solve a lot of problems - make sure to really struggle with a problem for a while first before taking a peek at the comments/solutions. Make sure to understand the solution properly. Maybe add some comments to the code stating the invariants, and why they hold true throughout.

    If the solution uses a new technique, read up on it. Search for other problems using the technique and solve those without peeking.

    What we should be aiming at is deliberate practice - don't waste time solving easy problems, solve problems that are just hard enough where it may just be possible to solve it, but only after a lot of struggle

    Almost everyone feels the same way, just with different levels of problems.