3203. Find Minimum Diameter After Merging Two Trees | Diameter of a Tree | Graph

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

КОМЕНТАРІ • 19

  • @ARYANMITTAL
    @ARYANMITTAL  4 місяці тому +12

    I guess this one was easier than Problem 3, what do you guys think?

    • @theexplorer9012
      @theexplorer9012 4 місяці тому +3

      same

    • @SDHANUSH-l9u
      @SDHANUSH-l9u 4 місяці тому +1

      Only problem here was to come up with an algo for Diameter 💀💀.
      Did not get this intuition of using one extreme to another extreme

    • @tanmaybro3812
      @tanmaybro3812 4 місяці тому

      yess

    • @thomasshelby6780
      @thomasshelby6780 3 місяці тому

      Have you gone crazy to go about privatising every video of your channel

  • @Jazzimus
    @Jazzimus 4 місяці тому

    My approach was slightly different but i think the underlying intuition is the same. Basically find the centroid of both the graphs. From the centroid, do DFS to find the 2 largest heights (their sum would result in the diamater of the respective tree) and the combined diameter would be sum of the largest height of each tree + 1. We would then take minimum of these values.

  • @subhadrosamaddar6336
    @subhadrosamaddar6336 4 місяці тому

    nice explanation bro
    🥰

  • @tejaschalke1778
    @tejaschalke1778 4 місяці тому

    My solution failed exactly on the "edge" case mentioned, it cleared my doubt why the answer is 7. Thanks!!!

  • @80-shreypatel96
    @80-shreypatel96 4 місяці тому

    please make video on leetcode 3202

  • @monishtyagi2354
    @monishtyagi2354 3 місяці тому

    why soln giving TLE

  • @tirthpatel-t6u
    @tirthpatel-t6u 4 місяці тому

    Why we cannot use median method , it is giving me wrong answer on 453 test case , if i just join two medians of different trees , please reply @ARYANMITTAL

    • @nutrinoflash6132
      @nutrinoflash6132 4 місяці тому

      you will need to track individual diameter of both the trees it could be the case that by joining two medians the path length is still smaller than any one of the two diameters

    • @tirthpatel-t6u
      @tirthpatel-t6u 4 місяці тому

      @@nutrinoflash6132 But how it can be , if am taking median , shoudln't the height is eqaul to half of diameter?

    • @theexplorer9012
      @theexplorer9012 4 місяці тому

      Overkill

    • @nutrinoflash6132
      @nutrinoflash6132 4 місяці тому

      @@tirthpatel-t6u ceil(x/2) + ceil(y/2) + 1

  • @rishabhgoel8936
    @rishabhgoel8936 4 місяці тому

    this solution gives tle , idk y

  • @shreyash184
    @shreyash184 4 місяці тому

    No Vedio on 1,2,3 ?

    • @ARYANMITTAL
      @ARYANMITTAL  4 місяці тому

      Already live on channel sir🫡😮‍💨