Skip to main content

Command Palette

Search for a command to run...

7 Things I Wish I Knew When I Started DSA

Published
4 min read
7 Things I Wish I Knew When I Started DSA
N

Hi, I'm a pre-final year student with a passion for programming, reading, and writing! This blog brings together all my interests in one place.

You took Physical Education as your elective in school. You took Music. You took Art. You had Java in Class 10th, but never applied it properly. You went to college expecting they'll teach you what you need to know. And then two years passed and suddenly, everyone around you is going seemingly crazy about summer internships and here you are — stumped. You might feel that your education system has betrayed you.

You might feel that you have no chance because there are only two months left and even the YouTubers who exaggerate for views say: "Three Months Road Map for DSA."

It's alright. I understand. I've been there.

So, here are 7 things I wish I knew then, and two more just for you:

1. DSA and competitive programming are two different things. Yes, DSA will come easier and quicker to you if you're well versed in CP, but it also doesn't give people who already know CP too much of a headstart. You're not too far behind. If you haven't done CP, it's fine. If you don't have a Codeforces account and don't know what a rating is — it's alright. Do DSA. Keep your understanding of both these things also separate. Also: two months is absolutely enough time. One month is enough time. Just start. You'll understand. Don't think you're too late. I swear you're not.

2. Leetcode, Leetcode & Leetcode: For an interview, focus on Leetcode 90% of the time, but give weekly/biweekly contests on platforms like Codeforces or CodeChef. That helps a lot.

3. Recursion: From the very beginning, focus on recursion. Backtracking, trees/graph traversals, dfs/bfs, dynamic programming etc., are all ultimately one thing: recursion. If you understand recursion very well, a lot of your work is already done. And if these terms are alien to you, worry not! You'll get there quicker than you think.

4. What you code today is less important than the notes you take about it. Revision is very important. Just because you've understood a concept well does not guarantee that you'll remember it. From the very beginning, make a Word Doc, where you note down any tips/hints/whatever new cool thing you understood, and keep a track of the questions that you've done. Please do this. I really regretted not doing my initial topics in here.

5. There are patterns. Don't do questions blindly. Keep writing down stuff you observe. You'll do a problem and be like "oh this is actually very similar to another problem I did before." Don't ignore that. That's a very important epiphany, it's at the very core of your preparation. Before you know it, most of the questions will be sorted in something I like to call "buckets." A bucket of questions that are solved using tortoise-hare algorithm. A bucket of questions on which you can use BFS/DFS traversal. It makes stuff easier to remember and also easier to revise right before an interview.

6. Follow an actual book along with whichever course or online DSA sheet you're following. I recommend the Competitive Programmer’s Handbook by Antti Laaksonen, whose free PDF can easily be found online. Keep checking you're covering everything up and also if you're understanding the full concept. And I'm not saying read the book. Just follow along and refer for conceptual doubts. A lot of times we skip over details that books usually cover.

7. Understand STL concepts very well. In the beginning, it's very difficult to transition from arrays to vectors, and start intuitively using stacks, maps, sets, etc. in questions. However, the sooner you force yourself, the more comfortable you'll soon become in them, which is very important.

Two final points:

One, because I see a lot of people struggling with this one:

Logic over everything else. Try making the problems smaller, easier to digest. Focus on the important parts in the question. Understand new algorithms, absolutely, but there's no problem where you can just use a standard algorithm if you don't really know what's going on. For someone a little more versed with DSA: don't apply greedy, think greedily. Don't apply DP, think dynamically.

And two, because this was a complete nightmare to me initially, only for me to realize how trivial it was:

Sorting. I know, I know, sounds stupid. But I spent about a whole week on all the different kinds of sorting, including ones like Radix sort, Bucket sort, etc. I found them difficult but felt I had to somehow understand them completely, in-depth, right at that very moment. My advice, in case you're by chance also somewhere there: don't. Understand Insertion Sort, Bubble Sort, Merge Sort and Quick Sort and then get used to the in-built sorting function.

And that's about it. I hope this list, while in an admittedly odd order of things, is still helpful. Thank you so much for reading!