21 November 2022 · 3 min read
What Is LeetCode, and Why Learn Competitive Programming?
What competitive programming is, which topics you need to start, how LeetCode fits in, and the advice I would give to someone just starting out.
This post is about competitive programming: what it is, how it improves analytical thinking and problem solving, and why it is worth solving DSA (data structures and algorithms) problems. I'll share what I know from my own experience.
What is competitive programming?
Competitive programming means combining your programming skills with algorithmic thinking to solve problems you are given. Picture yourself at the start line of a race. There are several routes to the finish, and each has obstacles. To finish as fast as possible you have to pick between them. What do you take into account? Your shoes, the shape and length of the road, how many people are on it, how many obstacles there are, and more.
Competitive programming works the same way. You get a programming problem and have to solve it under given constraints, with time and memory in mind. A correct answer is not enough, because the efficiency of your solution matters too. What sets you apart from other people is how fast you find a solution and how sensible it is.
What do you get out of it?
The biggest benefit is that your analytical thinking and your ability to design algorithms improve a lot. The more problems you see, and the more different solutions to them, the wider your view gets.
It also helps in job interviews. Besides the projects you have built, you will very likely be asked DSA questions. Many FAANG companies (Amazon, Facebook, Google, Uber, Twitter and so on) ask these questions in interviews. On Teamblind you can read posts by verified employees of those companies. Searching YouTube for "leetcode" will turn up more. Here is one video if you are curious.
How I mastered Data Structures and Algorithms
Which topics do you need?
To start, you should know a few basic data structures:
- Array
- Linked list
- HashMap
- Stack
- Queue
- Tree
And some basic algorithms and concepts:
- Search algorithms
- DFS
- BFS
- Time and space complexity
The list can look scary, but nobody was born knowing this. You get better by reading and solving problems over time. The most important thing here is patience.
What is LeetCode?
LeetCode is a site where you can solve a lot of programming problems online in the language you want, and prepare for job interviews at the same time. It is popular because it shares interview questions from many well-known FAANG companies for free. People also post their interview experiences and opinions there. Solving the popular problems on this site really does get you ready for software interviews quickly. Similar sites are HackerRank and Edabit, and you can look at those too.
Advice for beginners, and my own experience
I started competitive programming in January 2022, about 10 months before this post, after watching a video on Ahmet Buğra Çakıcı's YouTube channel. I was in the second year of university and taking the Data Structures and Algorithms course. I thought it would help with the course and improve my algorithm skills.
It widened my view a lot. Staring helplessly at problems I couldn't solve made me more determined. It helped my coursework too. I think I learned many algorithms and got a better grip on programming logic. Here is the video that got me started.
Solving 1000 algorithm problems on LeetCode, Hüseyin Ömer Güray
If you are just starting:
- Pick easy problems.
- If you can't solve a problem within 30 minutes to an hour, stop. Open "Discuss" at the top left of the problem page and read the popular solutions.
- You may lose motivation at first because you can't solve things. Keep going. You will see the phrase "keep consistency" all over the site, so remember it.
My LeetCode profile is here: https://leetcode.com/dareee/
Leave your thoughts and suggestions in the comments.