How to Implement an LRU Cache (Leetcode

แชร์
ฝัง
  • เผยแพร่เมื่อ 24 ธ.ค. 2024

ความคิดเห็น • 40

  • @ByteByByte
    @ByteByByte  5 ปีที่แล้ว +10

    I’m working on a bunch of new technical content. Let me know if there are any problems/algorithms you’d like to see me teach!

    • @Firstusee256
      @Firstusee256 5 ปีที่แล้ว

      Graphs and DP

    • @ByteByByte
      @ByteByByte  5 ปีที่แล้ว

      Dev- House any particular problems or algorithms?

    • @eyitayoogunbiyi2631
      @eyitayoogunbiyi2631 5 ปีที่แล้ว

      Please work on leetcode.com/problems/unique-binary-search-trees/ (dp + trees)

    • @quantumlexa
      @quantumlexa 5 ปีที่แล้ว +1

      it would be nice to see an explanation of KMP here

    • @smirkedShoe
      @smirkedShoe 5 ปีที่แล้ว

      Karastuba Algorithm

  • @sarthaksrivastav3408
    @sarthaksrivastav3408 4 ปีที่แล้ว +17

    This is by far the best explanation for this problem for me, you explained the whole thought process like why should we use map, why doubly linked list and not singly linked list etc. Thank you.

  • @adityasethi9794
    @adityasethi9794 11 หลายเดือนก่อน

    Lovely explanation man. The pace at which he talks and explains automatically makes it easy to understand.

  • @ChrisDieringer
    @ChrisDieringer 4 หลายเดือนก่อน +1

    Use of the map data-structure kind of hand-waves over the interesting bits of the O(1) requirement. That is to say, how can we assert that the backing map impl actually is O(1) for insert & put? Presuming the Map is actually backed by a tree, i'd wager that O(1) ops are not actually O(1), but probably O(log n). If a hashmap is used, you can get O(1) time, but given that O(1) was a key requirement of the video, "just use a map" may or may not be adequate explanation if you need to defend the solution to someone such as an interviewer. Agree/disagree?

  • @luzengyuan5326
    @luzengyuan5326 3 ปีที่แล้ว +2

    after i spent couple of hours for different videos, this is the best which explain clearly between doubly linked list and map. thanks

  • @PhilipMaessoumi
    @PhilipMaessoumi 8 หลายเดือนก่อน

    Thank you for your video, I had seen other videos using your type of solution for this problem, but you were the first one who explained it clearly.

  • @zn4798
    @zn4798 4 ปีที่แล้ว +1

    Do you have any code solution for that?

  • @michaelfulton8972
    @michaelfulton8972 3 ปีที่แล้ว +1

    WHAT IF WE HAD A MAP WHERE THE VALUE IS A POINTER TO THE NODE

  • @Tony-md7dr
    @Tony-md7dr 4 ปีที่แล้ว

    2:10 If 1 and 2 got added first, then 7 and 8 would go to the other end. You add items from the opposite end than where you remove items.

  • @mskumar225
    @mskumar225 5 ปีที่แล้ว

    @Byte By Byte we are not storing which element is the least recently used in the map. How do we know that 3 is the next least recently used element from the map? So, how we can directly go to that element from the list and delete it when we try to get the next element?

    • @ByteByByte
      @ByteByByte  5 ปีที่แล้ว +1

      We are maintaining the order in the linked list. So you remove the item from the end of the list and then looking it up in the map to remove it from there as well

  • @jlecampana
    @jlecampana 5 ปีที่แล้ว +2

    Hi Sam! It’s about time someone created a clear explanation to this problem! Hey, what App is that for the digital whiteboard? Thanks!

    • @ByteByByte
      @ByteByByte  5 ปีที่แล้ว +1

      jlstr Thanks! Glad you enjoyed it. And it’s an iPad app called Whiteboard Brush Whiteboard Brush by Lidong Chen apps.apple.com/us/app/whiteboard-brush/id496465537

  • @anilerengocer6254
    @anilerengocer6254 3 หลายเดือนก่อน

    Nice explanation.

  • @Hyperian
    @Hyperian 5 ปีที่แล้ว +3

    You should do way more of these!

    • @ByteByByte
      @ByteByByte  5 ปีที่แล้ว

      Hyperian that’s the plan! Anything specific you want to see?

    • @f3-faithfitnessfinance
      @f3-faithfitnessfinance 5 ปีที่แล้ว

      @@ByteByByte
      Spiral matrix 3

  • @AnantaAkash.Podder
    @AnantaAkash.Podder 7 หลายเดือนก่อน

    Thank you very much... A wonderful & nice explanation...

  • @guilhermenunes9776
    @guilhermenunes9776 2 ปีที่แล้ว

    Thankss... I finally understood how map connects with the linked list. I've watched so many videos O.o

  • @aileenchan3741
    @aileenchan3741 ปีที่แล้ว

    great video!

  • @marianopatino-paul5062
    @marianopatino-paul5062 3 ปีที่แล้ว

    Best explanation ever!!

  • @paulonteri
    @paulonteri 4 ปีที่แล้ว

    Nice explanation!

  • @prernacore
    @prernacore 4 ปีที่แล้ว

    such a clear explanation

  • @ehudklein
    @ehudklein 3 ปีที่แล้ว

    +1 on the doubly linked list

  • @sudhanshupandey8129
    @sudhanshupandey8129 4 ปีที่แล้ว

    Having a problem with DP problems.

    • @mounirkanane8083
      @mounirkanane8083 2 หลายเดือนก่อน

      Did you ever figure them out and if so what resources helped the most

  • @josiahdavid7735
    @josiahdavid7735 2 ปีที่แล้ว

    Thanks a lot man!!!!!

  • @ganeshchowdhary3024
    @ganeshchowdhary3024 5 ปีที่แล้ว

    Expert level competitive programming algorithms.

  • @rajhpking
    @rajhpking 5 ปีที่แล้ว

    Hi @bytebybyte u r earlier videos where u sit down and explains the problem and solves it was very effective than present few videos. Please start again same series of videos. Also explain how to use academic algorithms to solve leetcode problems. I find them very different and none of algorithm matches to most of leetcode problems.

  • @TP-xt4sv
    @TP-xt4sv 3 ปีที่แล้ว +3

    Am I the only one who think The person, who posted it, is really hot?