after hundreds of hours of grinding and explaining , I learned that there are different levels of preparation .
How to practice?
How many problems you should solve?
Common mistakes to avoid.
Whether leetcode is a total waste of time.
start with easy questions,used to study C++, first language I learned, it’s a mistake.
- Arrays
- Linked Lists
- HashMaps
- Trees
- Sorting
- Binary Search
solve problems in a random order which was another mistake
probably 60 or 70 questions and I switched up Python , and I saw up Python code was always the shortest and the most concise.Even though I had never used Python before and still to this day .
It was a easy choice to make because you don’t have to learn the entire language .
You really just have to learn the basic syntax /句法/ ,how to write if statement for loops and all the standard data structures and methods and you can actually learn these as you solve leetcode problems just by googling as needed .
C++isn’t a bad choice ethier , but I definitly avoid a verbose /冗长的/ language like Java , the language probably won’t be a deal breaker , but it can definitely save you a few minuntes when you’re typing out your code which can definitely make a difference in a real interview but it doesn’t matter how fast you type if can’t actually solve the problem and even after solving 100 problems while I had learned all of the high value algorithms like DFS(Depth-First Search)、BFS(Breadth-First Search)、Sliding Windows and Backtracking. /滑动窗口和回溯算法/。
I wasn’t able to consistently solve a new problem for the first time . I didn’t know it then but the reason was that a lot of leetcode questions are sequential , you’ve probably seen questions like House Robber 1 , House Robber 2 , House Robber 3 , obviously you should solve these questions in order but actually most leetcode questions should be solved in a specific order .
But actually most leetcode questions should be solved in a specific order. For example, you should never try solving dynamic programming problems unless you already have a solid understanding of backtracking and you probably shouldn’t try solving graph problems until you have a solid understanding of trees. This is obvious in hindsight , but I’m sure a lot of people make this mistake which is why I created a roadmap so that you don’t make the same mistake I did . It turns out that the order you solve problems that does matter. I also think that solving one or two problems a day consistently is a lot better than cramming because the ideas will actually stick if you need a little motivation I’ve been solving daily leetcode problems on my second channel .
As I continued , I realized that if I couldn’t solve a question in 45 to 60 minutes , I wasn’t gonna be able to solve it myself previously I would literally bang my head against the wall for 3 to 4 hours on a single problem , because I thought that was the only way to learn.
but let just be honest , most of us are not gonna be able to come up with some of these complex academic algorithms by ourselves and even if you can come up with Floyd’s tortoise and hair algorithm , it’s probably not an efficient use of your time , there’s no shame in looking at a solution as long as you can understand exactly why it works . That’s why in my videos I really try to explain my thought process behind every problem , this end up saving me a lot of time because I would get to a really hard problem , a cracked problem , I like to call them like burst balloons , and I would get pretty close to solving the problem I would know it’s a dynamic programming problem but I just couldn’t figure out the trick behind it . Then I would look at a solution and only after five minutes of reading I would realize , oh that’s the trick and then I would be able to immediately solve the problem . I was able to go from 100 to 250 solved questions a lot faster than I was able to solve my first 100 questions and by then I had learned 99 percent of the patterns that I needed , even some of the complex ones and I got to the point that writing out these algorithms like DFS , BFS and binary search was as easy for me as writing a for loop .
Even some advanced ones like union find Dijkstra. I could write out in less than five minuntes , and that’s when I realized that most of the leetcode problems fall into the following buckets .
For medium questions , you just need to figure out what algorithm you need and then apply it , hard questions are similar except there;s usually a really complex trick behind them and sometimes unless you’ve seen it before the god can help you figure that out .