Competitive Programming | Resources, Technique & Tips
Note that it has been a while since I was heavily involved in practicing, so the resources I'll mention might have been superseded already. However, I believe the technique will still be relevant.
Resources
I started by reading The Competitive Programming book and solving its UVa exercises. It was a little bit challenging to find solutions for some of UVa's questions, so here are some of my solutions . The second book I read was The Art of Problem Solving .
In parallel, I was participating in rounds from various online judges: Codeforces , Topcoder , CS Academy , AtCoder , Hackerrank , Hackerearth , Google Code Jam , Google Kickstart , Facebook's Hackercup , and Catalyst's Coding Competitions .
One of the most useful resources for you will be the resources that you develop and maintain while practicing. Be organized and save the important tricks, and information that you learn while practicing because you will need to revise them and you will need to get back to them when you are stuck in a similar problem. One example is to maintain a sheet for the most insightful (and only the most insightful so that it doesn't end up being full of noise and useless) problems you solved and what you learned from them, take a look at my problem sheet .
In my last year of practicing, I started contributing to the this curriculum and I believe that there is a significant effort put into it and that it is still well-maintained. Thanks to Ahmed Elsagheer for this amazing initiative.
Technique
The technique that I will advise for is to make sure that you are touching all of the following dimensions.
1. Topic-oriented Practicing?
To be able to solve more difficult and deep problems, you need different tools in your pocket. Basically, different Algorithms and Data Structures in this case. So your plan has to always include new algorithms and data structures that you are learning and practicing. By practicing, I mean that once you learn a new algorithm or a new data structure, you need to solve easy, medium, and hard problems using it. You need to make sure that it's not just a new tool in your pocket, but a new tool that you can really use. Just knowing the algorithm is not enough at all. By just knowing and memorizing the algorithm, you will just be able to solve straightforward problems using it. That's not helpful. You need to understand the algorithm and its variants deep enough to be able to tweak it and use for different use cases. Not just that, sometimes you will need it to solve a subproblem of the bigger problem so using it needs to come naturally to your mind by recognizing the patterns and the use cases that it comes in handy with. It's like practicing different chess plans. Will you iterate over all the chess plans you memorized in the middle of a game? It won't work, they will only come naturally to your mind after using them a lot.
2. Topic-agnostic Practicing
You don't want to overfit your brain on knowing the tool needed for the problem before being able to use it. That's where the role of general problem-solving practice comes. I used the online judges I mentioned above for this purpose. Note that you don't want to finish all easy problems in an online judge before starting to practice on medium and hard ones. If you just kept solving easy problems, you will be quite fast in solving the easiest problem in the contest and your mind won't help you in going deep enough to solve the harder ones.
3. Online Competitions Participation
You need to join online competitions and not just keep solving offline problems. Handling time and standings pressure in online competitions is an important key to getting high rankings. You might have already heard about strong problem solvers who do only underperform in online competitions. One important technique that helped me survive is to compete with myself instead of competing with others. Only monitor your progress and just learn from others.
4. Practicing Different Styles of Competitions
Don't stick with only one online judge or one flavor of competitions. Codeforces problems style is very different from the ICPC style. Contests with long and complicated statements are different from the ones that tell you the problem in a straightforward manner?Three-hour contests are different from five-hours contests. Individual contests are different from team contests. Participate in and solve problems from different sources. You can't practice for 100m runs and expect to perform in 1500m runs.
Tips & Advice
Do it if you enjoy it
If you don't enjoy problem-solving, then you will be torturing yourself by doing all this. Just find another way. Imagine someone who hates running but needs to practice it twice a day to be a champion. If I didn't enjoy it, I would have definitely lost hope and got desperate after my first couple of participations and if I kept trying then I would have been wasting time. Computer science has an abundance of interesting paths, don't limit yourself. One good litmus test is whether you'd consider practicing after graduating. By now I know a lot of people who haven't achieved much in competitive programming but flourished in other tracks.
Be patient, it takes time
Don’t expect to be able to solve hard problems quickly after one day or one week or one month of consistent practice. One doesn't go to the Gym and find themselves carrying the heaviest weights in the first month. Be ready for a lot of failures and the inability to solve a lot of problems. That's when you will learn. Whatever your level is, you should be investing time in trying to understand and solve problems that are not easy for you, so if you don't enjoy and embrace the complexity, you will suffer. That’s mainly because if at any point everything you are studying or trying to solve is easy for you then most probably you are not benefiting from that so much.
领英推荐
I imagine it as a neural network. When I first started practicing, I would have never ever imagined the complex problems that one day I will be able to solve. These complex problems I am talking about are super simple for another more experienced competitive programmer. So why can’t my brain just solve more difficult problems? It is not just knowledge. It is how deep can your mind keep exploring different approaches, and how many subproblems can your mind handle at once. This comes with practice. Your mind is capable of thinking in a complexity that you can’t even believe, but it needs practicing.
Be consistent
Consistently practice. One of the common traits you can find among highly-rated competitive programmers is consistency. I am talking about the daily amount of time they dedicate to competitive programming. That’s not a competitive-programming-specific tip. That’s something you should do to reach a high skill level of anything because usually it can’t be achieved in a short time and without consistency, you will not have the chance to build knowledge and train your mind. So dedicate a daily amount of time to practicing. Start with an hour or two and increase that every week.
Be brave and continue a plan
Don’t keep jumping between different plans. That’s super important and that’s one problem that I found a lot of people doing. That's mainly because it is easier and more satisfying to keep taking the easy part of every plan and solve more problems.
One of the things that makes people like playing games is that games bring a sense of achievement quickly after every level, we as humans love that feeling. So what most of the people who fail do, is they start a plan, and have fun at the beginning because it is always super easy like every start of every semester. When it is super easy, one can have a lot of achievements in a short time, whenever it starts to get harder they start a new plan. Don’t do that.
The time invested in picking the right plan for you is a time that is really well invested. So invest enough time picking the right plan and stick with it! To be honest with you, a huge amount of plans will just work the secret is in completing them and in being patient.
Find the room in which you are the most stupid
At the same time as you are practicing, working hard, and getting better and better, try to strive for finding rooms in which you will be the most stupid person. Not by pretending to be stupid, but by founding people who are smarter and more experienced than you. That’s something that helped me a lot. It was like a catalyst for me in my competitive programming journey. Surrounding myself with people who are much more smart and experienced than me, helped me develop my skills quickly. There is an abundance of those people, but you need to seek them.
Don't depend on others
One problem that I find a lot of people falling into is depending on one or a group of friends to study together and to motivate each other. Studying with one another occasionally is amazing and motivating one another is even better but you should never be depending on that. Try to drive and motivate yourself and others.
Avoid unhealthy comparisons
Don’t keep comparing yourself to others. Compare yourself only to yourself. Keep monitoring your progress. A lot of people will disagree with me on this point and they will say that this is competitive programming. I am not saying that they are wrong, but that just wouldn’t have worked with me for hundreds of reasons. For me, the competitive part of the word is about competing with myself and being a better version of myself. Let’s acknowledge that there will always be people better than you and let’s acknowledge that you will find them near you and if you don’t, then believe me you are not in the right place.
Help others
If you avoid comparing yourself to others, it will make it easier for you to wish them success. It will make it easier for you to help them. Helping others is super important for tons of reasons.
Be organized
You will learn tons of algorithms and you will see huge amounts of solutions, tips, and tricks, and you will solve or try to solve a lot of problems. I can assure you that if you are not organized and you are not having an index or a reference for the highlights you will blame yourself later while searching for something you have already learned or met before.
Don't neglect academic studies
Don't sacrifice investing time in your theoretical academic studies for competitive programming. Those are very important foundations that will help you distinguish in your future practical life.
Good luck and reach out if I can help ??
SDE @noon | ACPC finalist | master @CodeForces
2 年Mohammed Aladin? Mohamed Adel
Software Development Engineer @Amazon
2 年I've always been intrigued by your dedication to practice back in the day, truly inspiring ?? Thanks for sharing this ??
Software Engineer @Microsoft | 3x ACPC Finalist
2 年I liked the last point, in my 3rd year in uni ,I solved a lot of problems and problem solving become not fun as first year, I had.to stop long time because I started to hate it. Now I can solve only 5 problems per week but I enjoy doing it
Full-Stack Certified Product Manager (Growth - Data - AI - Ops) | PSPO
2 年Abdulrahman Moubarak
Software Engineer | Problem Solver
2 年Thanks for sharing