I solved 541 Leetcode problems. But you need only 150.

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
Coding Interviews are very easy. That’s what I thought when I went to Leetcode and attempted this “Rotate Array” as my very first problem After spending 6 hours on it I had not written a single line of code. I was extremely frustrated and went to the discussion section to read the most upvoted solution Another 2 hours passed and I could not even figure out why this solution works. At this point, my frustration had transformed into disappointment I somehow managed to put myself to sleep that night and the next morning, I went to a friend and asked him to solve the exact same question. And that’s when I learnt something really interesting about the human behavior If you can not solve a problem, you feel sad. But if your friend solves the exact same problem in under 15 minutes, you are heartbroken After facing many hurdles like that, I managed to solve 541 problems on Leetcode Along the way I collected many amazing job offers Today, I am going to share everything that I have learnt in the process. At the end of the video, I will also answer a very important question And that is “How to know if you are ready for interviews at big tech companies?” Before you can even start on Leetcode, you need to have a good understanding of “Data Structures and Algorithms” I have already covered this topic in my last video which I will link at the end. Once, I finished the basics of DSA, I went to the top interview questions on Leetcode There are exactly 150 problems in there and all of them are very important I recommend that if you are solving a problem which is outside these 150 problems, make sure that it’s your 151st problem. Now that you know where to start, let’s discuss what’s the right strategy to solve these problems I am sure you already know that all problems on Leetcode are tagged easy medium or hard based on difficulty level And if you look a little closer at the “Rotate Array” problem which was my very first problem on Leetcode, it’s tagged as a “medium” difficulty problem Starting my Leetcode journey with this problem was the first big mistake I made 2 other mistakes that I will share later in this video This problem was a mistake because if you are looking to stay motivated and actually improve your programming logic you have to start with easy problems As you solve some easy problems you will start collecting some tools for your toolbox And when you reach the medium problems you will be able to use some of these tools to tackle them This approach has 2 major advantages One, you will not lose your confidence like I did when I encountered my first medium problem The second and the bigger advantage according to me is that when you solve the medium problems, you will actually learn more from them Let me explain what I mean by this Imagine that you have not solved any easy problems and you try to solve a medium problem Let’s say you are not able to solve the problem and you look at the solution There is a good chance that you might not be able to understand the solution and even if you do it’s highly unlikely that you will grasp all the nuances of the solution So, having some easy problems under your belt is a must before moving to the medium problems Let’s go back to our “Top Interview Questions” and sort them by difficulty Solve these 37 Easy problems before you move on to the mediums Now that you know the high level Leetcode strategy, let's dig a little deeper and see how to approach any new problem And this where you will see a big difference between a Newbie and a Pro interviewee Let me tell you how a beginner solves any new problem They read the problem statement and immediately start coding a solution What they don’t understand is that we should leave multiprocessing to the computers Our brains are not built to think and code the solution at the same time Infact, as much as the productivity gurus would like you to not believe this we humans can not multitask Our focus is like a zoom lens of a camera, we can zoom in to see that one thing or we can zoom out to see more things but we can do both at the same time If you don’t believe me, you can try out this “Selective Attention Test” by Professor Simmons on Youtube I will link it in the description if you are with me on this, I would like you to break the process of solving a coding problem into 2 separate steps. Step 1 is coming up with the solution in your head and Step 2 is actually coding it up in the editor Sounds obvious, doesn’t it? Well, it’s not that simple You see, when most people are thinking about the solution what they are actually thinking about is how to code the solution and there’s a big difference between the two. To explain what I mean, let’s walk through this easy problem on Leetcode. In this problem, you are given the root node of 2 binary trees and you need to tell whether the 2 binary trees are the same You can pause the video here if you want to solve the problem yourself A beginner might look at the given function and start thinking about checking the value at the root node of both trees to see if it's the same. In the next step, they would start thinking how they can compare the value of the nodes to the left or the right of the root nodes This way of solving might work for this easy problem but if you are doing this, you are actually thinking about how to code the solution Now, I want you to forget that you know how to code. Just think about this Given the root nodes of 2 binary trees, What needs to be true for them to be the same. Value of the root node needs to be the same, the left subtree needs to be the same and the right subtree needs to be the same. Once you see that, the solution is just this one line of code where you check all 3 conditions Training your brain to differentiate between thinking about the solution and coding it up requires a lot of practice But if you practice enough, you will reach a place where you just have to think about the solution Once you have a clear solution, the coding part will start coming naturally to you. In my interviews, I rarely spend more than 15 minutes on writing the actual code Most of my time goes into thinking about the solution so keep practicing It might take 100 problems for some and 500 for others like me But you will eventually get there. Before we talk about how to know if you are ready for interviews, let’s talk about how to practice And this is where I made my second big mistake And that is I spent way too much time on one problem It was mainly because my ego was very high. How am I not able to solve this problem? Maybe if I give it a little more time? By doing this I would end up spending upto 3-4 hours on one problem In an interview, you only get 45 minutes to solve a problem Why should your practice session be so different? In my opinion, if you are not close to the solution in 1 hour, you should give up and spend the rest of the time on looking at the solutions of the others and learning from them So, go to the discussion section, sort the solutions by most votes and read at least the top 3 solutions I recommend 3 solutions and not just the top one because sometimes the top solution is not practical for the interviews Try to understand the solution rather than memorizing it because you will not be able to replicate the solution in the interview After understanding the solution, come back to the editor and code it up yourself. Even if you think you are writing the exact same solution that you just read, do it. That’s because many times, there are some corner cases that you will not be able to see just by reading And when you hit the test cases that don’t pass, you will appreciate the difference between “less than” and “less than or equal to” much better. But what do you do if you are able to solve the problem? And this is where I made my third and the final mistake After solving a problem, I would just move onto the next question. And that is not the best strategy because your solution might not be optimal It might pass all the test cases but there still might be some better solutions out there I recommend reading the top solutions no matter what. This is especially important if your solution is too lengthy and you think you can not solve problem in the interview time In my opinion, if you are writing a solution that is more than 20 lines of code, There’s a good chance that there’s a better solution out there So, there’s no harm in learning from others Many people ask me how to decide whether they are ready for coding interviews Are 200 problems enough or should I do 500? To be honest, it doesn’t work that way in life It’s less about how many problems you have solved, and more about how good you are at solving any new problem I believe that we should answer this question from an interview standpoint An interview is usually 45 minutes long and in most interviews, they ask you a Leetcode medium problems Accounting for the pressure of the interview and adding a buffer for the introductions, if you can consistently solve Leetcode mediums in less than 30-35 minutes, you are ready to go Reaching this level on Leetcode is impossible if you don’t have a strong foundational knowledge of Data Structures and Algorithms To learn how I mastered Data Structures and Algorithms, watch this video My name is Sahil and I will see you in the next one
Info
Channel: Sahil & Sarra
Views: 2,126,529
Rating: undefined out of 5
Keywords: leetcode, leetcode python, leetcode problems, data structures and algorithms in java, data structures and algorithms, coding interview, google coding interview, software engineer interview, cracking the coding interview, technical interview, how to use leetcode effectively, coding interview preparation, programming interview, faang interview preparation, data structures, algorithms
Id: xF554Tlzo-c
Channel Id: undefined
Length: 7min 42sec (462 seconds)
Published: Sat Oct 15 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.