WORD SQUARES (Leetcode) - Code & Whiteboard

Поділитися
Вставка
  • Опубліковано 15 гру 2024

КОМЕНТАРІ • 10

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

    This is super helpful and very clear explanation! Please make more videos!

    • @babybear-hq9yd
      @babybear-hq9yd  3 роки тому +2

      Thanks Vince!! I've got about 80 up at the moment, but I'll be pumping more out soon! Subscribe to stay tuned! :)

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

    cool explanation, thanks :)

  • @anolhshete
    @anolhshete 3 роки тому

    nice stuff...waiting for more of such videos

    • @babybear-hq9yd
      @babybear-hq9yd  3 роки тому

      ty! i've probably got about 80 uploaded so far, so plenty to catch up on :D

  • @barunkumar3276
    @barunkumar3276 3 роки тому

    Nicely explained, thanks!

  • @outlawdawn
    @outlawdawn 3 роки тому

    hashtables are O(1) set get so its very fast to get an item from it

  • @surters
    @surters 3 роки тому

    In prefixes they use setdefault and .add, this could just be style but it might have a performance effect.
    In the prefix generation you make a lot of compares, they just generate it all making the first "if prefix in prefixes" superfluous.
    In most other cases the lazy generation of the cache should be an advantage but as soon as most of the cases are used pre-generating the values should be an advantage.
    Idea for new video, test the effect of the different implementations and comment on why it is so, in this case the complexity of the two solutions are the same, yours is even slightly better as you don't have to generate all prefixes, only those who are actually used.

  • @ez7532
    @ez7532 3 роки тому

    Thank you!

  • @Hovane5
    @Hovane5 3 роки тому

    It’s faster because the lookups for sets are ~O(1)