What is competitive programming, and Why should you care.
Competitive programming is one branch of a larger tree. This tree broadly depicts various fields that a student must know about.
Only a handful of the names have been described here but there are many more like:
- Operating Systems
- Database Design
- Compilers
- Computer Vision
- Block Chain
- Cloud
- Cryptography
- etc
Competitive Programming as the name suggests - programming with competition.
One programmer competes with the other in terms of writing better code in lesser time, here by “better” i am referring to the complexity of your code.
Complexity — It is a way to compare the time that two pieces of code will take without actually executing them. read more
(Another article covering complexity in detail will soon follow)
Edit 19Sep : https://medium.com/programming-club-nit-raipur/complexity-it-is-not-that-complex-6b264a6139e6
How & Where do programmers compete ?
Programmers compete in contests hosted online on various platforms, some of them are listed below
These platforms also provide a large number of technical problems to practice (including non-programming).
Each problem has a specific task and a time-limit associated with it, your code should give the correct output within the time limit. (these conditions are only so that your submission is accepted but remember you need to solve before others do)
In most of the contests language of your choice is allowed, but this is not always the case.
A basic example:
Problem : You’re given N numbers, and for Q times you need to give the sum of first K numbers.
1 ≤ N < 10⁵
1 ≤ Q< 10⁵
1 ≤ K ≤ NTime Limit : 1s
N = 10
Q = 2
1 8 36 4 25 5 42 3 17 46K = 3
Output: 45K = 5
Output: 74
In the first glance, the problem appears very simple.
Solution1: Calculating the sum from 1 to K every time.
but hold your horses it is not that simple. Look again
This contains a crucial information from which you can eliminate the above solution by comparing complexity. Total : O(N . Q) in this case.
(do not worry if you don’t understand how, we will cover complexity in detail later on.)
Edit 19Sep : https://medium.com/programming-club-nit-raipur/complexity-it-is-not-that-complex-6b264a6139e6
Solution 2: Prefix Sum, ie we will pre-calculate sum of numbers till Kth and can then answer in complexity O(1).Total : O(N + Q) in this case.
It is all about optimization. (notice N.Q → N + Q)
……………………………………………………………………………………..
Why should you care.
Competitive programming is not only a sport that many enjoy but plays an important role in understanding different algorithms and developing a technical acumen.
This is a great way to showcase your programming ability and skills to the world.
If you’re a college undergrad and wants to work in IT industry and this doesn’t excite you, here is why you will have to do it anyway.
In your final/pre-final year companies visiting your campus would select you for internships & full-time after evaluating you. And you guessed right they conduct a very similar test as the programming contests.
Not only the companies visiting your campus but in general most of the companies have the 1st round as Aptitude and Coding this means before they would have seen your certificates, pointer(grades) or participation in extra-curricular they will filter purely on your technical knowledge and skills.
Avoid Pitfalls
Competitive Programming is not a silver bullet, and literally never ends.
As long as you can code without hesitation and have knowledge of algorithms you’re good to go.
A jack of all trades is a master of none, but oftentimes better than a master of one
I recommend you to explore different fields and do not stick only to one, at the same time do not try to do everything.
This is the first article. more will soon follow
In case of any issue or suggestion you can reach me at aditya999123@gmail.com.