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

preview_player
Показать описание


0:00 - Read the problem
0:30 - Drawing Explanation
9:19 - Coding Explanation

leetcode 2471

#neetcode #leetcode #python
Рекомендации по теме
Комментарии
Автор

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

jonTheDon
Автор

This is an array question not a tree one !

Trownekos-gchu
Автор

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

EranM
Автор

Hashmap Jutsu, i am using this one 😆😆

shoryakhanna
Автор

Doing the complete swap was very helpful. Thank you!

shanemay-gunlogson
Автор

comparing to sorted array felt like cheating

pranaytalekar
Автор

Make a 2d array with each notations and apply a function to count the minimum operation to sort each array

MrEngineer-di
Автор

What if the elements were not distinct, can we still use the same approach to find min swaps?

AbhijeetPadhy
Автор

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?

PedanticAnswerSeeker
Автор

can you solve the same question with multiple

prajapati-suraj
Автор

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.

rohitkumaram
Автор

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

vijethkashyap
Автор

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

Kaviarasu_S
visit shbcf.ru