How I mastered Data Structures and Algorithms

This is you in a Coding interview. And this is 
the dream job that you really want. If you don’t   prepare data structures and algorithms, there’s 
a good chance that you will be rejected. Now,   I am no Love Guru when it comes to 
relationships. But for coding interviews,   I do have some expertise. And to crack all these interviews, the only course I have ever used is called Data Structures and Algorithms.

And the best 
part is that I did not master DSA sitting in   a classroom of a fancy university. 
I did it online, all by myself,   because I have no Computer Science degree. 
Today, I will share my entire journey in detail   so that you don’t repeat the same mistakes 
that I made when I was struggling with DSA. Before we go too deep into how to 
learn data structures and algorithms,   we need to first understand what data structures 
and algorithms means. Believe it or not,   you might have already used data structures and 
algorithms in your life. For example, I want you   to remember the time when the meaning of every new 
word was not available on Google and you had to   use an actual physical dictionary to look up the meaning of 
a word. To find a word, let’s say “programming”,   you would open the dictionary in the middle and look at 
the words that are there on that page.

Let’s   say you landed on a page with words starting 
with “m”. You know that “m” comes before the   “p” of programming. So, the word “programming” 
must come after the page you just opened. So,   you start looking for “programming” in the right 
half of the dictionary. If you repeat this step   multiple times, you will end up finding the 
word programming. The process or in other words,   the algorithm that you just saw is called “Binary 
Search''. And the way data is stored, which   is “dictionary” in this case, is called a data 
structure . Don’t confuse this “dictionary” with   the data structure “dictionary” that we might have seen in Python because they are slightly different. But why does a Software Engineer even need 
data structures and algorithms? Imagine that   in the dictionary example I just gave you, someone 
starts from the beginning and keeps flipping one   page at a time to find the word 
“programming” .

It will take them many   minutes to find just this one word. With “binary 
search”, you will find it in a matter of seconds.   That’s the power of algorithms. Now imagine 
that instead of giving you a dictionary where   the words are neatly organized in alphabetical 
order, I gave you a bag full of paper slips each   containing a word and its meaning. How long do you think 
it would take you to find the word “programming”? At   least a few hours unless you are really lucky. 
That’s the power of ‘Data Structures'.

I hope that this example makes you even more 
excited about learning Data Structures and   Algorithms.To make learning DSA easier for you, 
I recommend that you learn at least one Object   Oriented Programming language before you start 
DSA. That’s because most online resources for   DSA will be using an object oriented programming language. 
You can pick any popular language like Java,   Javascript, C++ or Python. If you already 
have a language that you are comfortable with,   you can continue with that. But if you don’t, 
I recommend that you pick Python for DSA.   That’s because Python is less verbose and you 
can write code really fast in Python. And in   an interview, where you only have 45 minutes to 
solve a question, this would be really helpful. Now that we have that out of the way, let's talk 
about how I started my DSA journey. If you have   seen any of my previous videos, you know that 
I am a strong advocate for “Learning by Doing”.   Unfortunately, for DSA, I don’t think there is 
any good resource that you can jump   into and start learning by doing.

That’s because 
DSA requires a good theoretical foundation before   you can actually apply it to any problems. 
That’s why, I took the online course   route for DSA. I used this course called Algorithms by Princeton University on Coursera.   This course is divided into 2 parts and is taught in Java. But if you are looking for a good DSA course in languages other 
than Java, I do have some recommendations for   you later in the video. Professor Sedgewick, who 
is one of the instructors of this course, is   famous for taking the worst case space complexity 
of Quicksort from big o of n to big o of logn in   5 extra lines of code. If you don’t know 
what that means, don’t worry about it. The point   I am trying to make here is that this course is 
taught by the best of the best.

The instructors   of this course have seen many algorithms come and 
go during their career. Their book on Algorithms   has been a bestseller since the 1980s. That’s why 
instead of just saying: “here are data structures   and algorithms that exist”, they are able to 
provide a complete context of why a particular data   structure or algorithm exists and when to use 
it. And purely from a learning standpoint,   this course make you fall in love with algorithms. I can not recommend this course enough. But there is one big issue when it comes to 
learning DSA. Most people don’t know how much   is enough and where to draw the line. And I 
also made a same mistake here. This is the first   of the 3 big mistakes I made on my journey. I will share the other 2 later in the video.

The mistake I made was that I   I ended up completing both algorithms 1 and algorithms 2. I realized it much later in my journey that I did not need full   Algorithms 2 for coding interviews. If I could 
go back in time, I would skip the entire Week 3   and everything after Week 4. I am not saying that 
these things are not useful, it’s just that they   are rarely asked in the interviews. And even if 
there is some uncommon question that uses them,   you would be able to solve it if you follow what 
we are going to discuss in the rest of the video. Anyway, if Java is not your primary 
language and you want to use C++ instead,   there’s this course by IBM that you can 
use. If Python is your language of choice,   you can use this free course by Google on 
Udacity. This Udacity course might not be   free in your country but it’s free in the US.

All 
the links will be in the description. By the way,   in case you are wondering, I do not 
get paid anything if you use any of   the resources I am recommending today. So, the only 
way to support us is by subscribing. After finishing a course on DSA, you will 
become very powerful. And you might start   believing that you can bend the entire 
universe to get that dream job. And that   would be the second big mistake that I made. I 
applied for many jobs after completing DSA but   it did not get me anywhere. That’s because 
knowing all these different algorithms and   actually applying them to a new problem 
are very different things. Add the   interview time limit of 45 minutes on top of that 
and it suddenly starts looking like an impossible   task.

For those who are having a hard time 
finding a job even after learning DSA, trust me,   I have been in your place. Here is how I solved 
this issue. I went to Leetcode and started solving   some interview questions there. If you don’t 
already know, Leetcode is pretty much the best   resource out there to practice DSA questions. All the 
questions are labeled easy medium or hard based   on difficulty level. In the beginning, you might 
not be able to solve medium or hard problems. So,   stick to easy questions. And when easy problems 
really become easy for you, move on to the mediums   and so on. And when 
mediums start feeling easy, you are ready for   the coding interviews. If you want me to make 
a full video on how to use Leetcode efficiently,   let me know in the comments. Another resource that 
I would like to mention here is “Top 10 algorithms   in interview questions” on GeeksforGeeks. If you 
have done your Leetcoding well, you would already   know most of the algorithms here. But, it’s still 
a good place to revise what you have learnt.

But before you start applying for jobs, it’s very 
important to set your expectations right. The   first few interviews are most likely going to be 
a disaster. And that’s perfectly fine. That’s why,   I recommend that you don’t start by applying 
to your dream companies in the beginning. Do   some practice by applying for companies that 
might not be your top choice. And once you   are doing well there, move on to the ones 
that you really desire. And always remember   that rejections are part of the process. Like 
they say, there are two ways to walk in life.   The first is to walk like you are the king of 
the world.

The second one is to walk like you don’t   give a f**k who the king is. Choose the second 
one and don’t let anyone’s opinion discourage   you from working towards your goal. And 
as always, we are here to support you. Before I forget, let me tell you the third 
big mistake that I made. I used to think   that mastering DSA will make sure that I can crack 
any software engineer interview. But in reality,   DSA is not the endgame. You still need 
to impress the hiring managers and crack the behavioral interviews. If you 
want to know how to do that, you can watch this video at the top. My name is 
Sahil and I will see you in the next one.