Minimum Number of Operations to Sort a Binary Tree by Level - Leetcode 2471 - Python

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

КОМЕНТАРІ •

  • @Trownekos-gc4hu
    @Trownekos-gc4hu 3 дні тому +11

    This is an array question not a tree one !

    • @Axel.Blazer
      @Axel.Blazer 3 дні тому

      it aint even a question..had we had to return the tree then it would be a medium..the question's prerequisite is lvl order traversal..cuz arrays n sorting is done probably undrr lecture 15

  • @jonTheDon28
    @jonTheDon28 2 дні тому +2

    It would be cool to see a video of you solving a problem that you don't already know the solution to. I want to see what you're thought process is like. I understand that a vid like this would probably be very long but i think it would still be a cool concept

  • @karthi7102
    @karthi7102 3 дні тому +3

    As always GOAT

  • @shanemay-gunlogson9575
    @shanemay-gunlogson9575 2 дні тому

    Doing the complete swap was very helpful. Thank you!

  • @EranM
    @EranM 3 дні тому +1

    i actually used a min_heap, instead of sorting.. and i mapped everything but still failed it.. dunno why

  • @shoryakhanna8342
    @shoryakhanna8342 3 дні тому +3

    Hashmap Jutsu, i am using this one 😆😆

  • @tharunkumar5095
    @tharunkumar5095 3 дні тому +2

    Does count inversions work here??

    • @raymartin77
      @raymartin77 3 дні тому +1

      No. Ex [3, 2, 1] there are 3 inversions but only 1 swap is needed

    • @tharunkumar5095
      @tharunkumar5095 3 дні тому

      @raymartin77 okay
      Thank you!!

    • @pratee-n9d
      @pratee-n9d 3 дні тому +1

      it works when only adjacent swapping is allowed

  • @pranaytalekar8865
    @pranaytalekar8865 3 дні тому +1

    comparing to sorted array felt like cheating

  • @PedanticAnswerSeeker
    @PedanticAnswerSeeker День тому

    Cant we do this with two lists? compare the sorted list with the current list, check where the indexes dont match, and return the answeR?

  • @prajapati-suraj
    @prajapati-suraj 3 дні тому +1

    can you solve the same question with multiple approaches...........

  • @vijethkashyap151
    @vijethkashyap151 3 дні тому

    With the swaps, how are we guaranteed that its the minimum number of swaps? Does cyclic sort guarantee minimum number of swaps?

    • @Axel.Blazer
      @Axel.Blazer 3 дні тому

      because whatever you change index to, it goes back to correct position..also any standard sort i think shouls not work because here our stuff works below linear time..its a custom sort =)

  • @rohitkumaram
    @rohitkumaram 3 дні тому

    Mostly you upload the solution the moment it appears in daily challenge.
    I know there is time_zone difference , but curious to know how do you manage sleep and other stuff with this.

    • @bubblesort8760
      @bubblesort8760 3 дні тому +1

      Probably he prepared this video a few days before the problem actually appeared.

    • @michaelmwenyachileshe2901
      @michaelmwenyachileshe2901 2 дні тому

      @@bubblesort8760 how does one know which problem is coming, or do you think he just hopes a video he's already done will come

  • @kannergrassfed3359
    @kannergrassfed3359 2 дні тому

    hashmap jitsu for the win 😀

  • @Kaviarasu_NS
    @Kaviarasu_NS 3 дні тому

    as we don't need to update the mapping of
    idx_map[nums[ i ]] = i
    we also don't need to swap
    nums[ i ] = nums[ j ]
    and our final solution be like
    j = index_map[sorted_nums[ i ]]
    nums[ j ] = nums[ i ]
    index_map[nums[ j ]] = j

  • @kenaj30
    @kenaj30 3 дні тому +1

    :D