Premiered Oct 15, 2022
1. How to use Leetcode effectively?
2. How to learn Data Structures and Algorithms?
3. How to use Leetcode solutions?
4. Whether to use Python for Leetcode?
5. How to crack coding interview?

I will answer all these questions in this video.

► FREE resources:
1. Leetcode Top Interview Questions: ...
2. Selective attention test: ...

► For more content like this, subscribe to our channel:

► Follow us on Linkedin:

► Let's be FRIENDS! ...

► For business inquiries, reach us on:

#datastructures #datastructuresandalgorithms #leetcode #codinginterview

DISCLAIMER: All opinions shared on this channel are our own and don't express views or opinions of our employers. We only use our experiences and public knowledge to make our content. NO CONFIDENTIAL INFORMATION of our employers is used or shared on this channel. This is not a Professional Coaching channel, it only highlights the public resources that have worked for our careers.

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