[Java] Leetcode 159. Longest Substring with At Most Two Distinct Characters [Sliding Windows #2]

Поділитися
Вставка
  • Опубліковано 24 січ 2025

КОМЕНТАРІ • 19

  • @tunepa4418
    @tunepa4418 3 роки тому +2

    Nice! Other solutions feel like magic, when they update the left pointer to the least recently seen element

  • @abhilashpatel3036
    @abhilashpatel3036 Рік тому +1

    so much simplified explanation. thanks!

  • @valkon_
    @valkon_ 3 роки тому +1

    Thanks a lot for the clear and calm explanation, I complete misunderstood it.

  • @ramfattah275
    @ramfattah275 3 роки тому +1

    🐱‍👤Wow! this is actually a premium question on leetcode. Thank you for sharing your knowledge! 👏

  • @Rob-J-BJJ
    @Rob-J-BJJ Рік тому +1

    Nice this one was a little confusing so i gotta restudy it

    • @EricProgramming
      @EricProgramming  Рік тому

      Practice makes perfect and there are a couple more videos that are similar to this, so worth trying as well

    • @Rob-J-BJJ
      @Rob-J-BJJ Рік тому

      @@EricProgramming thx i learned it after going thru it a couple times

  • @FunForestFood
    @FunForestFood 3 роки тому +1

    Sir nice explanation 🙏🙏

  • @isaiahparker6170
    @isaiahparker6170 Рік тому

    Good video. What's the time and space complexity of the solution?

  • @Troglodyte2021
    @Troglodyte2021 Рік тому

    thank you very much❤

  • @wonghuang1830
    @wonghuang1830 2 роки тому

    Thank you!

  • @khai9719
    @khai9719 2 роки тому

    can someone explain the second part of the HashMap...why inside of the hm.put its hm.getOrDefault(arr[R], 0) + 1), like what is that saying exactly?

    • @filipkojic6208
      @filipkojic6208 2 роки тому

      He checks if character arr[R](as a key) exists in the map and returns the number of its repetitions, or 0 if it doesn't.So when hm.put is executed it either puts the key arr[R] for the first time with 1 as the number of its repetitions, or incremented value of the previous number of repetitions.

  • @Rnenrococcmfnfmrmelsosocnrn
    @Rnenrococcmfnfmrmelsosocnrn 2 роки тому

    If we know that K is two why can't we just do hm. remove(arr[L]) ? Instead of decrementing it first?

  • @prashantshinde5318
    @prashantshinde5318 2 роки тому

    for this example what python libraries in basics we have to study...and is this kind of examples are asked in FAANG interviews?