Skip to main content

Beginners guide to Competitive Programming



Beginners guide to Competitive Programming
In this blog I will be sharing my experience and provide some tips to those who want to start competitive programming or has already started it but don’t know how to proceed. Before we begin, I want to clarify that I don’t consider myself a great coder but since I am coding for almost a year I have gathered some experience and have also made some mistakes in the beginning which I want to share so that no one repeats them.
Let’s begin then.
So the first question that comes to everyone’s mind is
Why Competitive Programming?
Because it’s FUN . That adrenaline rush when you see ‘Running’ written on the screen and you wait to see whether you solved the problem correctly or not. Seeing your name climb up the leaderboard with each problem you solve. Being first to solve a problem that your friends are desperately trying to solve. Frustration after repeatedly getting ‘Wrong Answer’ . It’s a mix of different feelings and more of a journey in which you would learn as well as enjoy yourself.
Now that you feel motivated to start, next question is
Where to start?
With so many online sites and resources it’s very natural that one will be confused. So, to make things easier I will be going through some of the most popular sites for competitive programming and mention their specialities so that you can decide yourself which one suits you the best.
SPOJ


Probably one of the most popular sites among the coders, it has thousands of problem with varying difficulty and whenever you are stuck on a problem just google the name of that problem and you will surely find an editorial or a solution . There is also a SPOJ Toolkit to test your code on different test cases and compare your output with the correct answer. I would highly recommend solving at least first hundred most solved problems on Spoj, it would improve your thinking skills and you would approach a problem more algorithmically rather than in a brute way .
CODEFORCES


Codeforces on an average hosts ten short contests in a month with duration between 2–3 hours. As the name suggests, Educational Rounds are a great source for learning. Although I would recommend participating in online contest after a month or two of practicing so that you are confident enough of yourself .
CODECHEF


Codechef hosts three main contests in a month-Long challenge, Cook-off and Lunchtime. Long challenge has eight problems with difficulty increasing after each question and you have ten days to solve them. Long challenge is a great source for learning new concepts and if you give them sincerely you are bound to learn at least one new thing. Cook-off is two and a half hours long contest and comprises of 5 problems. Lunchtime is codechef’s another short contest and it also comprises of 5 problems and you have three hours to solve them.
HACKEREARTH

Hackerearth provides topic wise questions which helps you in strengthening a particular topic. It also has a tutorial at the start of each topic which covers its basic concepts. It also hosts a lot of college contests along with Circuits and Easy, two of the monthly contests hosted by hackerearth. Circuit is quite similar to Codechef Long Challenge.
Now that you know where to start ,next thing is
Pick a Language
You should choose a language and become so proficient in it that you can implement any algorithm without any difficulty. The four most popular languages are:
C++ : Most used language especially because of ‘STL’ which makes life so much easier by most of the needed things already declared.
C : Mostly same as C++ but lacks some features like ‘STL’. If you already know C, learning C++ might be a good option.
JAVA : Slower as compared to C/C++ but has big integer class which might be useful sometimes. If the time limit is too strict, solution written in Java might not pass.
PYTHON : It is also slow and has big integer class. In spite of being slow, some coders prefer it because you can implement the same thing in fewer lines of code as compared to C/C++.
Now that you have selected a programming language, next thing you need to know is
Basic Terminology
Imagine that you have written a code and submitted it with the hope of getting a green tick but instead the judge shows ‘SIGSEV ERROR’. You can correct your code only if you know the cause and that’s why having a basic knowledge of some of the most used terms is essential.
Few of the Runtime errors you might face are:
SIGSEV


Most popular error and is called ‘segmentation fault’. It occurs when your program accesses a memory location which is not assigned to it, say a negative array index or a pointer pointing to null address.
SIGABRT
Occurs when judge aborts your program in the middle of execution. It can also be manually caused using an ‘assert’ statement in C++, which is useful for debugging purposes. Insufficient memory is another cause for it.
SIGXFSZ
Occurs when your program has printed too much data to output ,i.e, ‘output limit exceeded’.
MLE
This type of error occurs when your program allocates more memory than allowed.
TLE


TLE or ‘Time limit exceeded’ , is not a runtime error but occurs when your program takes more time to produce output than allotted for a problem. It may be caused by an infinite loop or an inefficient algorithm.
These are the most frequent errors, the list of errors dosen’t stop here. To get a more insight about errors , you should probably check this link.
Last thing that I want discuss is
Mistakes That Beginners Make
Getting Demotivated Easily
In the beginning it is possible that you spend a complete day on a problem and still not be able to solve it. You may lose confidence, but think this way, every time you are not able to solve a problem and check the solution you learn something new. Next time you will be able to solve the question that requires that concept yourself.
Procrastination
A habit that a lot of programmers have. Think of the regret you will have when you see a question in a contest that requires a concept which you have been procrastinating to learn. So it’s always better to learn something that you have been planning to, as soon as possible and not delay it for long.
Solving Only Easy Questions


If you are able to solve five problems continuously without any difficulty then you are not learning anything. You have to challenge yourself with a more difficult problem each time because this is the only way to improve. It dosen’t matter if you are able to solve it or not every time you learn something.
Not Implementing yourself
Whenever you read a new algorithm or an editorial it’s very important that you implement it yourself. ‘You don’t know an algorithm unless you can code it yourself ’. If you don’t implement it yourself you will soon forget it. Try to practice 2–3 questions from that topic.
At the end i would like to say that competitive programming is just like a sport, as in every sport some people may like it, some may not, some may find it difficult to play with but as in every sport it is, if you wish to become good in it, practice and sheer practice is the the only key. That’s all you need to know for a start, I hope you enjoyed this article and will find it useful. Stay tuned for some more amazing content.
Happy Coding!


Written by:- Shubham kumar Jha
Source:- https://medium.com/nybles/beginners-guide-to-competitive-programming-60300af1ee92

Comments

Popular posts from this blog

What is Blockchain Technology?

A  Blockchain , initially  Block chain , is a developing rundown of records called blocks, which are connected utilizing cryptography. Blockchains which are decipherable by people in general are broadly utilized by cryptocurencies. Private blockchains have been proposed for business utilize. Here, is a short story which will make you comfortable with the  Blockchain Technology . Mario and Luigi Mario needs to send $100 to his brother, Luigi, because Luigi being Luigi, he got into some debts at the other end of the world. Mario walks into the bank and says “I’d like to send $100 to Luigi”. The Cashier says “Account card please”, “ID please”, ”signature” and “done”. In this centralized situation, the bank is the *central* expert over Mario's and Luigi's cash. Both Mario and Luigi trust the bank to exchange the sum, and trust the numbers appeared on their bank account statements. They trust the bank in-spite of the way that all the bank needs to do is change

Android Livedata and MutableLiveData

Open Event Android   Android Livedata and MutableLiveData December 14, 2018 Problem Suppose that we need to perform actions in light of changes in lifecycle status of Android Component. Some of the time you may wanna observe certain qualities being changed over the setup change. We all faced these problems somewhere down the road, trying a lot of different patterns MVP, MVVM, and others. But to implement these patterns is also a big problem for beginners. Solution The good news is that with the Android Architecture Component and more precisely with the lifecycle LiveData and ViewModel , we can easily overcome these problems. LiveData LiveData is an observable data holder. It is also a lifecycle aware. By lifecycle aware I mean, it can only be observed in the context of a lifecycle, more precisely in the context of an Activity or Fragment lifecycle. By passing the reference of an Activity or Fragment , it can understand whether

Why use Snackbar instead of Toasts?

Open Event Android   Why use Snackbar instead of Toasts? January 14, 2019 Problem Toasts are kind of deprecated as any user who has disabled notifications for an app won't be able to see toast as well. The Open Event Android App was using toast for displaying information. So the task is to completely remove toasts and use snackbar instead. Solution Why Snackbar? Snackbars provide lightweight feedback about an operation. They show a brief message at the bottom of the screen on mobile and lower left on larger devices. Snackbars appear above all other elements on screen and only one can be displayed at a time.They automatically disappear after a timeout or after user interaction elsewhere on the screen, particularly after interactions that summon a new surface or activity. Snackbars can be swiped off screen. The Difference Snackbar Contain a single line of text directly related to the operation performed. They may contain a text action,