3373. Maximize the Number of Target Nodes After Connecting Trees II | Graph | DP on Trees | Greedy

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

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

  • @ARYANMITTAL
    @ARYANMITTAL  День назад +2

    C++ Code - leetcode.com/problems/maximize-the-number-of-target-nodes-after-connecting-trees-ii/submissions/1467126572/
    Please do share with your friends or social media, it will be super super helpful 🥺

  • @vision-into-future
    @vision-into-future День назад +1

    Liked your approach which is definitely more intuitive, here's my approach which i felt a bit simpler.
    - use BFS similar to Q3, but this time instead of pre-computing count of neighboring nodes

  • @rrrhitk
    @rrrhitk День назад

    Really liked the approach

  • @Jazzimus
    @Jazzimus День назад +1

    there was one more key observation to this problem which made it trivial: if for some node "node" its even count and odd count are (x, y); then for its neighbours the even and odd count will be (y, x). They just get inverted. We then just have to find maximum such odd from Tree2 and add that to an even[i] from tree1 to get the answer (for some i)

  • @asmitshukla4649
    @asmitshukla4649 День назад

    made the logic and explanation TOO MUCH COMPLICATED, cant understand anything after a point