Evaluate Boolean Binary Tree - Leetcode 2331 - Python

Поделиться
HTML-код
  • Опубликовано: 29 ноя 2024

Комментарии • 16

  • @potansiyel7021
    @potansiyel7021 6 месяцев назад +8

    My friend, I want to examine your brain. After so many leetcode questions, I think you have an extremely superior brain.

  • @preritpradeep
    @preritpradeep 6 месяцев назад +4

    Hey Neetcode, Whenever you get some free time can you please solve the problem - Number of Wonderful Substrings. I haven't been able to find a single good video explaining the intuition of how to solve such problems. Thank you in advance! 😃

  • @sreyanth99
    @sreyanth99 6 месяцев назад +5

    Shoutout to laddoo gang.
    Video was helpful as ever, thank you neetcode for the neat code.

  • @gabrielvrldev
    @gabrielvrldev 6 месяцев назад

    Thanks for keep posting the solutions of the daily challenges! It's helping me a lot this past few days!

  • @ahmedtremo
    @ahmedtremo 6 месяцев назад +4

    I think the recursive solution is O(log n) as it's a full binary tree

  • @deadlyecho
    @deadlyecho 6 месяцев назад

    I solved it iteratively using 2 stacks for simplicity

  • @heetvadiya3629
    @heetvadiya3629 6 месяцев назад +2

    Never this early, hello neetcode 😊🎉

  • @yassine-sa
    @yassine-sa 6 месяцев назад

    You didn't really need a hashmap even if using it doesn't hurt performance much I suppose, I avoided it doing the following:
    Whenever I encounter a leaf node, I pop again, if what I just popped isn't leaf, I add the previous leaf and and then add the non leaf, if both nodes are leaf, I pop the operator again and evaluate both of them and append the result. If this wasn't a tree and was some sort of a graph then yes a hashmap would be useful to not evaluate a node multiple times( number of times it's referenced)

  • @yassine-sa
    @yassine-sa 6 месяцев назад

    The iterative approach is medium if not quite hard

  • @advaitbajaj4241
    @advaitbajaj4241 6 месяцев назад +1

    Which laddoo do you like bro?

  • @priyanshagarwal8490
    @priyanshagarwal8490 6 месяцев назад

    2055. Plates Between Candles... Next Please..

  • @pastori2672
    @pastori2672 6 месяцев назад

    the iterative solution is just as efficient as the recursive one right ?

    • @NeetCodeIO
      @NeetCodeIO  6 месяцев назад +1

      yeah thats right

  • @aashishbathe
    @aashishbathe 6 месяцев назад +7

    LADDOO REFERENCE AGAIN!

  • @scuderia6272
    @scuderia6272 6 месяцев назад +2

    Ladooo 😂