Leetcode刷题经验贴(B站up转述)

本文分享了作者在准备LeetCode时的学习经验,强调了问题解决的顺序、语言选择(如C++vsPython)、数据结构理解和高级算法的重要性,以及如何避免无效学习时间,通过有计划地练习和理解解决方案来提高效率。
摘要由CSDN通过智能技术生成

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.

  1. Arrays
  2. Linked Lists
  3. HashMaps
  4. Trees
  5. Sorting
  6. 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 .

  • 18
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值